.env file formatter
Format and validate .env files: keep the original order, sort alphabetically or group by key prefix, drop duplicate keys (keeping the last value), align equals signs, collapse stray blank lines and quote values when needed.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
What this tool does
- Bring every .env in the team to one style: aligned equals signs, tidy blank lines, keys sorted alphabetically or grouped by prefix.
- Clean up duplicate variables left over from copy-paste, keeping the last one that actually wins at runtime and reporting what was dropped.
- Quote values consistently so spaces or # characters are not read as comments during deployment.
Example
Input
PORT=8080 API_URL=https://example.com API_KEY=secret PORT=3000
Output
API_URL = https://example.com API_KEY = secret PORT = 3000
The original order is kept and duplicates are deduped (the last PORT wins). Pick "Alphabetical" to sort by name or "Group by key prefix" to block API_ / DB_ style keys together.
Frequently asked questions
Which duplicate value is kept?
The last one, which is also the value that wins at runtime. The number of removed lines and the duplicated key names are reported under the result.
Does aligning the equals signs change anything?
No. KEY = value and KEY=value are identical to dotenv; alignment is purely cosmetic and quoting rules are unchanged.
Does sorting scramble my comments?
Comments move together with the variable that follows them. A comment block at the very top of the file (followed by a blank line) is treated as a file header and stays in place.
Will values be quoted automatically?
Only when needed: values containing spaces, #, quotes or newlines get double quotes with newlines and quotes escaped. You can also force quoting always or never.
Keywords:envdotenv.env 格式化env formatter环境变量sort envdedupe去重对齐等号config file