Developer Config

.env formatter

What to do

Nothing typed here leaves your browser, but a .env holds secrets, so paste with that in mind.

Processed in your browser · nothing is uploaded

Local · quoted only where the value needs it
Advertisement
320 × 100

Normalises a `.env` file: `KEY=value` with no spaces around the equals, keys uppercased with underscores, an `export` prefix removed, and quotes added only where the value needs them.

How to use the .env formatter

1 Paste your input. The result appears immediately.
2 Pick the operation you want.
3 Copy the result, or save it as a file.

The spaces are the bug this exists for. KEY = value looks correct and is not: most .env loaders read everything after the first = literally, so the value becomes " value" with a leading space. That produces failures that make no sense. A URL that will not connect, a token rejected as invalid, because the whitespace is invisible everywhere you would look for it.

Quoting follows the same logic. A value containing a space, a #, a quote or a $ needs quotes or it will be truncated at the space, read as a comment, or interpolated. A value that needs none is left bare, because unnecessary quotes are themselves a source of confusion: some loaders strip them and some do not, and a value of "abc" including the quotes is a very annoying bug.

A .env is not a shell script even though it looks like one. export is accepted by some loaders and ignored by others, multi-line values are supported inconsistently, and command substitution is not supported at all by most. Keep values simple and single-line.

Questions

Most loaders take everything after the first = literally, so the value gains a leading space. That is invisible and breaks connections.

The Twelve-Factor App, config
Advertisement
300 × 250
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding