.env File Formatter & Validator
Paste a .env file to validate its format, detect duplicate keys, sort alphabetically, and optionally strip values to produce a .env.example. Runs entirely in your browser.
100% client-side · your secrets never leave your device
How to format a .env file
- Paste your
.envfile content into the input panel. - Toggle options: sort alphabetically, strip comments, or strip values.
- The formatted output and analysis appear automatically.
- Click Copy and paste the result into your file.
Common use cases
- Generate .env.example: Enable "Strip values" to produce a template safe for version control.
- Find duplicate keys: Check the analysis panel to detect silently-ignored keys.
- Standardise format: Sort and clean .env files before sharing with teammates.
- Audit variables: Count declared variables and spot empty values before deploying.
Related tools: Dockerfile Linter · GitHub Actions Linter · .gitignore Builder · All DevOps Tools
常見問題
- Is my .env file sent to a server?
- No. All processing runs in your browser. Your environment variable keys, values, and secrets never leave your device — not even temporarily.
- What .env format is supported?
- The standard KEY=value format used by dotenv, Docker Compose, and most deployment platforms. Lines starting with # are treated as comments. Blank lines are preserved or stripped depending on your settings.
- How does the formatter handle quoted values?
- Quoted values (KEY="some value" or KEY='some value') are parsed correctly, preserving the quotes in the output. This is important for values that contain spaces, equals signs, or special characters.
- Does it detect duplicate keys?
- Yes. Duplicate keys are flagged as warnings in the analysis panel. In most dotenv implementations, the first definition wins, so later duplicates are silently ignored — a common source of bugs.
- What is a .env.example file and how do I generate one?
- A .env.example file lists all required keys with empty or placeholder values, checked into version control. Use the "Strip values" mode to produce a .env.example from your real .env.
- Should I commit .env files to Git?
- No. Add .env to your .gitignore and commit only .env.example. Real .env files contain secrets. Use a secrets manager (AWS Secrets Manager, HashiCorp Vault, Doppler) for production.
- Does sorting break anything?
- Alphabetical sorting is safe for most applications. dotenv load order only matters if you have variable interpolation (KEY2=$KEY1) — in that case, KEY1 must appear before KEY2.
- What is variable expansion in .env files?
- Some dotenv libraries support variable interpolation: DB_URL=postgres://$DB_USER:$DB_PASS@$DB_HOST/mydb. The formatter shows interpolated references in the analysis panel so you can verify the correct load order.