.env Formatter
Clean, sort, and perfectly align your environment variables.
Tidy environment files without hand editing
A .env file grows organically. Keys are added at the bottom, someone pastes a duplicate from another project, and spacing drifts. This formatter reads KEY=value lines and produces a neat, column-aligned listing in which each variable name appears exactly once, so you can see the real configuration rather than a pile of overrides.
How to use it
- Paste your variables into the Input Data box, one per line. The Sample button loads a Laravel-style example that includes a repeated APP_ENV.
- Press Process / Generate.
- Look at the aligned output and the summary line, which reports how many unique keys were formatted.
- Choose Copy to grab the text or Download to save it as result.txt. Clear resets the box.
Exactly what changes
- Whitespace around each key and value is trimmed, and the text is split at the first equals sign only, so values that contain = are left intact.
- Keys are padded to the width of the longest name so the equals signs line up in one column.
- When a key appears more than once, it is listed at the position of its first appearance but carries the value from its last appearance, which mirrors how most loaders let later lines win.
- Blank lines and lines starting with # are skipped, as is any line without an equals sign.
Good moments to reach for it
- Comparing your local .env with .env.example before onboarding a teammate.
- Finding out which value actually wins after a merge conflict left two DB_HOST lines.
- Making a config snippet readable for a screenshot or a support request.
- Auditing a long file for repeated variable names.
Cautions before copying the result back
Comments are removed from the output, so do not overwrite a commented file without saving the notes elsewhere. The order is not alphabetical; it follows first appearance. The output also puts spaces around the equals sign for readability. Many dotenv libraries accept that, but a shell that runs source .env or Docker's env-file loader may not, so delete the spaces if you need strict KEY=value form. Quotes around values are kept as typed. Because .env files often hold secrets, review the output before pasting it into public issues. The formatting runs in JavaScript within your browser page.
Related Articles
Related Tools