An environment variables cli tool backed by SQLite
envelope is a modern environment variables manager.
…You can install envelope from homebrew-core:
$ brew install envelopeYou can download the envelope binary in the latest
release and copy the
binary to a folder in your $PATH
You can install envelope with cargo, make sure that your ~/.cargo folder is in
your $PATH
$ cargo install --git https://github.com/mattrighetti/envelope
$ envelope --version
envelope 0.3.11There is an aur package that packages the binary, called envelope-bin:
yay -S envelope-binenvelope is written in Rust. You'll need the Rust compiler.
$ git clone https://github.com/mattrighetti/envelope
$ cd envelope
$ cargo build --release
$ ./target/release/envelope --version
envelope 0.7.1Initialize envelope in your current directory. This creates a .envelope database file.
$ envelope init[!NOTE] You must run
envelope initbefore using any other commands. The.envelopefile should be added to your.gitignoreto avoid committing sensitive environment variables.
Pipe .env files to envelope to get a pretty format representation of the file
…Import from .env file
$ envelope import dev .env
$ envelope list dev
API_KEY=your_api_key_here
AWS_ACCESS_KEY_ID=your_access_key_id
DATABASE_URL=postgres://user:password@localhost:5432/mydb
DEBUG_MODE=true
SECRET_KEY=mysecretkey123
SMTP_HOST=smtp.example.comIt's also possible to import directly from stdin
$ cat .env | envelope import prodList all saved environments:
$ envelope list
dev
staging
prodList environment variables of a particular environment:
$ envelope list dev
API_KEY=your_api_key
DATABASE_URL=postgres://user:password@localhost:5432/mydb
DEBUG_MODE=true
SECRET_KEY=mysecretkey123
SMTP_HOST=smtp.example.comPretty print with a table format:
$ envelope list dev --pretty-print
+-------------+----------------------------------------------+-------+
| ENVIRONMENT | VARIABLE | VALUE |
+-------------+----------------------------------------------+-------+
| dev | DATABASE_URL | pos.. |
+-------------+----------------------------------------------+-------+
| dev | SECRET_KEY | mys.. |
+-------------+----------------------------------------------+-------+
...Truncate long values in pretty print mode:
$ envelope list dev --pretty-print --truncateSorting Options
You can specify the sorting order using the --sort option:
key or k: Sort by key in ascending ordervalue or v: Sort by value in ascending orderdate or d: Sort by creation date in ascending orderkd: Sort by key in descending ordervd: Sort by value in descending orderdd: Sort by creation date in descending order (default)Example:
$ envelope list dev --sort kd
SMTP_HOST=smtp.example.com
SECRET_KEY=mysecretkey123
DEBUG_MODE=true
DATABASE_URL=postgres://user:password@localhost:5432/mydb
API_KEY=your_api_keyAdd environment variables to an environment:
$ envelope add dev api_key sk_test_123456789
$ envelope list dev
API_KEY=sk_test_123456789Variable names are automatically uppercased:
$ envelope add dev database_url postgres://localhost/mydb
$ envelope list dev
DATABASE_URL=postgres://localhost/mydbRead value from stdin for sensitive data:
$ envelope add dev secret_token --stdin
Enter value for env secret_token:
my-super-secret-tokenAdd a variable with an empty value:
$ envelope add dev optional_var
$ envelope list dev
OPTIONAL_VAR=Delete a specific variable from an environment (soft delete — can be reverted):
$ envelope delete --env dev --key API_KEY
$ envelope list dev
# API_KEY will no longer appearDelete a variable across all environments:
$ envelope delete --key DEBUG_MODE
# Removes DEBUG_MODE from all environments where it existsDelete an entire environment:
$ envelope delete --env dev
$ envelope list
# dev will no longer appear[!NOTE] Envelope always soft deletes environment variables. They are never actually removed from the database, which allows you to view the history and revert changes. For a hard delete that permanently removes data, use the
dropcommand.
Drops (hard deletes) an environment and permanently removes all its variables from the database:
$ envelope drop dev
$ envelope list
# dev is permanently deleted, including all its history[!WARNING] Unlike
delete, thedropcommand permanently removes all data. This cannot be undone and you will not be able to view history or revert changes.
Create a copy of an existing environment:
$ envelope add dev api_key sk_dev_12345
$ envelope add dev database_url postgres://localhost/devdb
$ envelope duplicate dev staging
$ envelope list staging
API_KEY=sk_dev_12345
DATABASE_URL=postgres://localhost/devdbThis is useful for:
Example workflow:
# Create a backup before experimenting
$ envelope duplicate prod prod-backup
# Make changes to prod
$ envelope add prod api_key sk_new_key
# If something goes wrong, restore from backup
$ envelope duplicate prod-backup prodOpen your $EDITOR to interactively edit environment variables:
$ envelope edit devThis opens your default editor with all variables in the format:
API_KEY=your_api_key
DATABASE_URL=postgres://localhost/mydb
DEBUG_MODE=trueEditing tips:
=#:#API_KEY=your_api_keyNEW_VAR=new_valueWhen you save and close the editor, envelope will:
Check which environment(s) are currently exported in your shell:
$ export $(envelope list dev)
$ envelope check
devCheck works by comparing your current shell's environment variables against all stored environments. It will show all environments whose variables exactly match what's currently exported.
Multiple environments can match if they share the same variables:
$ envelope add shared-config api_key sk_12345
$ envelope duplicate shared-config also-shared
$ export $(envelope list shared-config)
$ envelope check
shared-config
also-sharedIf no environment matches completely, nothing is returned:
$ envelope check
# No output means no environment is fully activeEncrypt the envelope database. You will be prompted for a password and a confirmation.
$ envelope lock
Password: ********
Confirm password: ********
database locked successfully[!NOTE]
When the database is locked, you'll be prompted to unlock it when needed. You can still run commands on a locked envelope.
Decrypt the envelope database with the password you set when locking it.
$ envelope unlock
Password: ********
database unlocked successfullyCompare two environments to see their differences:
$ envelope add local db_connection http://localhost:3030
$ envelope add local dev true
$ envelope add prod db_connection https://proddb.com
$ envelope add prod db_user pg
$ envelope add prod db_pwd somepwd
$ envelope diff local prod
# DB_CONNECTION=http://localhost:3030 -> https://proddb.com
- DB_PWD=somepwd
- DB_USER=pg
+ DEV=trueThe output shows:
# lines: Variables present in both environments but with different values- lines: Variables only in the target environment (prod)+ lines: Variables only in the source environment (local)Use cases:
# Compare development and production configs
$ envelope diff dev prod
# Verify staging matches production
$ envelope diff staging prod
# Check what changed before deploying
$ envelope diff current-prod new-prodRevert a variable to its previous value. Each call to revert moves one step back in history:
$ envelope add local db_connection http://localhost:3030
$ envelope add local db_connection http://localhost:2222
$ envelope add local db_connection http://localhost:3333
$ envelope list local
DB_CONNECTION=http://localhost:3333
$ envelope revert local db_connection
$ envelope list local
DB_CONNECTION=http://localhost:2222
$ envelope revert local db_connection
$ envelope list local
DB_CONNECTION=http://localhost:3030Practical example:
# Accidentally set wrong API key
$ envelope add prod api_key sk_wrong_key_12345
# Oops! Revert to the previous value
$ envelope revert prod api_key
# Back to the correct key[!NOTE] Revert works because envelope keeps a complete history of all changes. You can revert multiple times to go back through the entire history. Use
envelope historyto see all historical values before reverting.
Run a command with environment variables from a specific environment automatically injected. This avoids the need to manually export variables into your shell.
$ envelope run dev -- cargo runYou can run any command and its arguments. The -- separator is optional but recommended when your command includes its own flags.
If you wish to clear the inherited envs from the parent process, you can use the
--isolated flag and that will make sure only the selected env variables are
injected in the subprocess.
$ envelope add prod ENVIRONMENT=prod
$ envelope run prod env
PATH=...
HOME=/Users/matt
SHELL=/bin/zsh
ENVIRONMENT=prod
$ envelope run prod --isolated env
# only PATH is inherited from parent
PATH=...
ENVIRONMENT=prodUse cases:
View the complete history of a variable, including deleted values:
$ envelope add local db_connection http://localhost:3030
$ envelope add local db_connection http://localhost:2222
$ envelope add local db_connection http://localhost:3333
$ envelope history local db_connection
2025-01-01 00:00:00 DB_CONNECTION=http://localhost:3030
2025-02-01 00:00:00 DB_CONNECTION=http://localhost:2222
2025-03-01 00:00:00 DB_CONNECTION=http://localhost:3333View deleted variables:
$ envelope add dev api_key sk_old_key
$ envelope add dev api_key sk_new_key
$ envelope delete --env dev --key api_key
$ envelope history dev api_key
2025-01-01 10:00:00 API_KEY=sk_old_key
2025-01-01 11:00:00 API_KEY=sk_new_keyUse cases:
# Initialize envelope in your project
$ cd my-project
$ envelope init
# Import existing .env files
$ envelope import dev .env.development
$ envelope import prod .env.production
# Add .envelope to .gitignore
$ echo ".envelope" >> .gitignore# Switch between environments
$ export $(envelope list deNo open issues yet, or sync has not completed.