Zero Signup ToolsFree browser tools

Developer Tools

Env File Formatter

Sort, align, and clean up a .env file in your browser. Group keys by prefix, align the equals signs, remove duplicates, and normalize quoting. No upload.

0 variables

Formatted .env

The cleaned and sorted .env file appears here. Paste your file on the left, or click Load sample.

What each control does

  • Group by prefix sorts keys so everything before the first underscore stays together, so all DB_, AWS_, and STRIPE_ variables sit in their own blocks.
  • Align the equals signs pads each key to the same width so the values line up in a column.
  • Remove duplicate keys keeps only the last value for each key, which is what dotenv libraries do at load time.
  • Quote only when needed drops quotes from simple values and adds double quotes back to any value with spaces, hashes, or special characters.

Parsing rules and privacy

  • Lines like export KEY=value, KEY="value", and KEY='value' are all recognized. A # after a space starts a comment; a # glued to the value stays part of the value.
  • Full-line comments and blank lines are preserved in Keep original order mode. When you sort, comments are kept above the variables so the reordered keys read cleanly.
  • Use Mask likely secret values before sharing a screenshot. The mask is only applied to the displayed output, never sent anywhere.
  • Everything runs in your browser with local string operations. Your .env file and the secrets inside it are never uploaded.

How to use

  1. Paste your .env file into the input box, or click Load sample to start with a deliberately messy example.
  2. Pick a sort mode: keep the original order, sort keys A to Z or Z to A, or group keys by the prefix before the first underscore.
  3. Turn on the cleanups you want: align the equals signs, remove duplicate keys, normalize the export prefix, and choose how values are quoted.
  4. Use Uppercase keys, Remove comments, Remove blank lines, or Blank line between groups to fine-tune the layout.
  5. Toggle Mask likely secret values before sharing a screenshot, then read the formatted file on the right.
  6. Click Copy to grab the result, or Apply to input to keep editing from the formatted version. Everything stays in your browser.

About this tool

Env File Formatter takes one dotenv-style .env file and rewrites it so it is consistent, sorted, and easy to read. It is the in-place tidy step that sits between the two other dotenv tools here: the converter changes a file into JSON and back, and the diff checker compares two files, while this tool keeps the format the same and simply cleans up a single file. Paste a messy .env, with mixed casing, ragged spacing around the equals signs, stray duplicate keys, and out-of-order variables, and read back a version that is sorted and aligned the way you want. The parser recognizes the practical subset of dotenv syntax that dotenv-node, python-dotenv, pydantic-settings, viper, docker compose, and GitHub Actions all accept: KEY=value lines with an optional export prefix, double-quoted values with escape sequences, single-quoted literal values, unquoted values, blank lines, full-line comments, and end-of-line comments after unquoted values. A hash that follows whitespace begins a comment, while a hash glued to the value is kept as part of the value, matching how real loaders behave, so the formatter never changes what your application reads. Sorting offers four modes. Keep original order preserves the file exactly, including the position of every comment and blank line, and only applies the formatting options you turn on. Keys A to Z and Keys Z to A reorder every variable alphabetically. Group by prefix sorts keys so everything before the first underscore stays together, which puts all DB_, AWS_, and STRIPE_ variables into their own blocks, and an optional blank line between groups makes those blocks easy to scan. Alignment pads each key to the same width so the values line up in a clean column, or you can keep the compact KEY=value form. Deduplication removes repeated keys and keeps the last value, which is exactly what dotenv libraries do when they load a file, so the formatted output matches runtime behavior. Quoting can be left untouched, forced to double quotes for every value, or reduced to the minimum so simple values lose their quotes while any value containing spaces, hashes, dollars, or backticks is safely wrapped in double quotes. You can also normalize the export prefix across every line, uppercase keys to the conventional SCREAMING_SNAKE_CASE, collapse runs of blank lines, drop comments, or remove blank lines entirely. A live count shows how many variables and duplicates the file contains, and likely secret values such as API keys, tokens, and passwords can be masked in the output so you can paste a screenshot into a ticket without leaking credentials. Everything runs in your browser with local string operations; your .env file and the secrets inside it are never uploaded, logged, or stored.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools