@webbies.dev/dotenvify
v1.0.2
Published
Convert messy environment variables into clean .env files
Maintainers
Readme
DotEnvify
Convert messy key-value pairs into clean, standardized .env files.
Transform this:
API_KEY
a1b2c3d4e5f6g7h8i9j0
DATABASE_URL
postgres://user:password@localhost:5432/dbInto this:
API_KEY=a1b2c3d4e5f6g7h8i9j0
DATABASE_URL="postgres://user:password@localhost:5432/db"After doing this manually one too many times, this tool was rage-coded into existence. You're welcome.
Install
npm install -g @webbies.dev/dotenvifyOr run directly without installing:
npx @webbies.dev/dotenvify vars.txt -o .envPermission errors (EACCES):
# Option 1: Use npx (no install needed)
npx @webbies.dev/dotenvify [commands]
# Option 2: Fix npm permissions (recommended)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH # Add to ~/.bashrc or ~/.zshrc
npm install -g @webbies.dev/dotenvifyWindows PowerShell: If you get an execution policy error, use Command Prompt (cmd.exe) or run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell as Administrator.
Usage
dotenvify <source> [options]# Convert a file to .env (default)
dotenvify vars.txt
# Custom output path
dotenvify vars.txt -o production.env
# Add export prefix to all variables
dotenvify vars.txt --export
# Overwrite existing .env without backup
dotenvify vars.txt -f
# Preserve specific variables (keep their existing values)
dotenvify vars.txt --preserve "DATABASE_URL,API_KEY"
# Only extract URLs, skip lowercase keys
dotenvify vars.txt --url-only --skip-lowerOptions
| Option | Alias | Description |
|---------------------|-------|----------------------------------------------------------|
| --output <file> | -o | Output file path (default: .env) |
| --export | -e | Add export prefix to all variables |
| --overwrite | -f | Overwrite output without creating a backup |
| --preserve <vars> | -k | Comma-separated variables to keep existing values for |
| --skip-sort | | Maintain original order (default: sorted alphabetically) |
| --skip-lower | | Skip variables with lowercase keys |
| --url-only | | Include only variables with HTTP/HTTPS URL values |
Supported Formats
DotEnvify auto-detects and handles all of these, even mixed in the same file:
# KEY=VALUE
API_KEY=a1b2c3d4e5f6g7h8i9j0
# Quoted values
SECRET="my secret value"
# export prefix (stripped automatically)
export NODE_ENV=production
# Space-separated
REDIS_HOST localhost
# Key on one line, value on the next
DATABASE_URL
postgres://user:password@localhost:5432/dbLines starting with # are treated as comments and ignored.
IDE Plugins
Prefer working in your editor? DotEnvify has IDE plugins with features beyond the CLI: Azure DevOps integration,
paste-and-format, and real-time .env diagnostics.
| | Plugin | Highlights | |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|-----------------------------------------------------------| | | IntelliJ, WebStorm, GoLand, PyCharm, Rider | Azure DevOps variable groups, paste & format, diagnostics | | | Visual Studio Code | Parser, formatter, diagnostics |
Upgrading from v0.x (Go version)
v1.0 is a full rewrite in TypeScript. If you're upgrading, read this.
What's different
| | v0.x (Go) | v1.x (TypeScript) |
|------------------|----------------------------------|-----------------------------------------------------------------------------------------------------|
| Runtime | Pre-built Go binary | Requires Node.js 18+ |
| Install | Binary via postinstall script | Standard npm install |
| Command | dotenvify -azure -group "Vars" | dotenvify vars.txt -o .env |
| Azure DevOps | Built into CLI (-azure flag) | Removed. Use the JetBrains plugin |
| Self-update | Built-in (-update) | npm update -g @webbies.dev/dotenvify |
| Parsing | Same formats supported | Same formats supported |
Breaking changes
- Azure DevOps is no longer in the CLI. Variable group fetching has moved to
the JetBrains plugin, which provides a richer experience
with IDE integration. If you relied on
-azure,-org, or-groupflags, install the plugin instead. - Node.js 18+ is now required. The Go binary is no longer distributed.
- Flag names changed.
-nlis now--skip-lower,-nsis now--skip-sort,-outis now--output/-o. - No subcommand. Usage is
dotenvify <source>(notdotenvify convert <source>).
Links
License
MIT. Go wild, make millions, just don't blame us when it formats your grocery list.
