Command-line interface providing all library functionality plus additional tools for cross-platform environment variable management, git integration, and development workflow automation.
# Global installation
npm install -g @dotenvx/dotenvx
# or
curl -sfS https://dotenvx.sh | sh
# Usage
dotenvx [command] [options]Run a command with environment variables loaded from .env files.
dotenvx run [options] -- <command>
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])
-fv, --env-vault-file <paths...> path(s) to your .env.vault file(s)
-o, --overload override existing env variables
--convention <name> load a .env convention (available: nextjs, flow)Usage Examples:
# Run node app with .env loaded
dotenvx run -- node index.js
# Run with specific .env file
dotenvx run -f .env.production -- node server.js
# Run with multiple .env files (priority order)
dotenvx run -f .env.local -f .env -- npm start
# Run with overload (override existing env vars)
dotenvx run --overload -- python app.py
# Run with convention
dotenvx run --convention nextjs -- npm run dev
# Run any language/command
dotenvx run -- python manage.py runserver
dotenvx run -- rails server
dotenvx run -- go run main.go
dotenvx run -- ./my-binaryGet environment variable value(s) from .env files.
dotenvx get [key] [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])
-fv, --env-vault-file <paths...> path(s) to your .env.vault file(s)
-o, --overload override existing env variables
--convention <name> load a .env convention
-a, --all return all env vars
--format <format> return format (default: "default", options: "default", "shell", "eval")
-pp, --pretty-print pretty print outputUsage Examples:
# Get specific variable
dotenvx get API_KEY
# Get from specific file
dotenvx get DATABASE_URL -f .env.production
# Get all variables
dotenvx get --all
# Get all in shell format
dotenvx get --all --format shell
# Output: API_KEY=secret123 DB_URL=localhost
# Get all in eval format
dotenvx get --all --format eval
# Output: API_KEY=secret123
# DB_URL=localhost
# Pretty print all variables
dotenvx get --all --pretty-printSet environment variable in .env files.
dotenvx set <key> <value> [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])
--convention <name> set a .env convention
-e, --encrypt encrypt the set value (default: true)
-p, --plain store value as plain textUsage Examples:
# Set encrypted variable (default)
dotenvx set API_KEY secret123
# Set in specific file
dotenvx set DATABASE_URL postgres://... -f .env.production
# Set in multiple files
dotenvx set SHARED_SECRET secret -f .env.development -f .env.staging
# Set as plain text
dotenvx set PUBLIC_URL https://api.com --plain
# Set with convention
dotenvx set NEXT_PUBLIC_API_URL https://api.com --convention nextjsEncrypt .env files or specific keys.
dotenvx encrypt [key] [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])Usage Examples:
# Encrypt entire .env file
dotenvx encrypt
# Encrypt specific key
dotenvx encrypt SECRET_KEY
# Encrypt specific file
dotenvx encrypt -f .env.production
# Encrypt multiple files
dotenvx encrypt -f .env.development -f .env.productionDecrypt .env files or specific keys.
dotenvx decrypt [key] [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])Usage Examples:
# Decrypt entire .env file
dotenvx decrypt
# Decrypt specific key
dotenvx decrypt SECRET_KEY
# Decrypt specific file
dotenvx decrypt -f .env.productionGenerate public/private keypair for encryption.
dotenvx keypair [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])Usage Examples:
# Generate keypair for .env
dotenvx keypair
# Generate keypair for specific file
dotenvx keypair -f .env.production
# Generate keypairs for multiple files
dotenvx keypair -f .env.development -f .env.productionList .env files in a tree structure.
dotenvx ls [directory] [options]
Options:
-f, --env-file <filenames...> path(s) to your env file(s) (default: [".env*"])
-ef, --exclude-env-file <excludeFilenames...> path(s) to excludeUsage Examples:
# List all .env files in current directory
dotenvx ls
# List from specific directory
dotenvx ls ./config
# List with custom pattern
dotenvx ls -f "*.environment"
# List with exclusions
dotenvx ls -f ".env*" -ef ".env.example"Rotate encryption keys.
dotenvx rotate [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])Usage Examples:
# Rotate keys for .env
dotenvx rotate
# Rotate keys for specific file
dotenvx rotate -f .env.productionPrevent .env files from being included in Docker builds.
dotenvx prebuild [directory] [options]Usage Examples:
# Setup prebuild for current directory
dotenvx prebuild
# Setup for specific directory
dotenvx prebuild ./docker-appThis command modifies build configurations to exclude .env files from Docker images.
Prevent .env files from being committed to version control.
dotenvx precommit [directory] [options]
Options:
-i, --install install to .git/hooks/pre-commitUsage Examples:
# Setup precommit hooks
dotenvx precommit
# Install as git pre-commit hook
dotenvx precommit --install
# Setup for specific directory
dotenvx precommit ./my-projectThe ext command provides access to extended functionality and plugins.
Enhanced file listing with tree structure.
dotenvx ext ls [directory] [options]
Options:
-f, --env-file <filenames...> path(s) to your env file(s) (default: [".env*"])
-ef, --exclude-env-file <excludeFilenames...> path(s) to excludeGenerate .env.example files.
dotenvx ext genexample [directory] [options]
Options:
-f, --env-file <paths...> path(s) to your env file(s) (default: [".env"])Usage Examples:
# Generate .env.example from .env
dotenvx ext genexample
# Generate from specific file
dotenvx ext genexample -f .env.production
# Generate in specific directory
dotenvx ext genexample ./configAppend patterns to .gitignore, .dockerignore, .npmignore, and .vercelignore.
dotenvx ext gitignore [options]
Options:
--pattern <patterns...> pattern(s) to gitignore (default: [".env*"])Usage Examples:
# Add .env* to ignore files
dotenvx ext gitignore
# Add custom patterns
dotenvx ext gitignore --pattern ".env.local" --pattern "*.key"Extended prebuild functionality.
dotenvx ext prebuild [directory]Extended precommit functionality.
dotenvx ext precommit [directory] [options]
Options:
-i, --install install to .git/hooks/pre-commitScan for leaked secrets in files.
dotenvx ext scanUsage Examples:
# Scan current directory for secrets
dotenvx ext scanManage .env.vault files (dynamic extension).
dotenvx ext vault [command] [options]This extension provides additional vault file management capabilities.
All commands support these global options:
Options:
-l, --log-level <level> set log level (default: "info")
-q, --quiet sets log level to error
-v, --verbose sets log level to verbose
-d, --debug sets log level to debug
-h, --help display help for commanddotenvx works with any language or framework:
# Node.js
dotenvx run -- node server.js
dotenvx run -- npm start
# Python
dotenvx run -- python app.py
dotenvx run -- flask run
# Ruby
dotenvx run -- ruby app.rb
dotenvx run -- rails server
# Go
dotenvx run -- go run main.go
# Rust
dotenvx run -- cargo run
# PHP
dotenvx run -- php index.php
# Any executable
dotenvx run -- ./my-binary
dotenvx run -- java -jar app.jar