dotenv → JSON

.env to JSON converter

Paste a dotenv file and get the object it actually produces — with duplicates and empty values called out instead of hidden.

0 characters

Your .env contents are parsed in this tab. Nothing is uploaded, stored or logged — this is the last file that should leave your machine.

Short answer: paste the file, copy the JSON. Keys keep their order, values stay strings, and a redefined key is reported with both line numbers so the lost value is not a mystery.

The three ways a .env file surprises people

What it does not do

It does not expand $VARIABLES from the environment, because the environment is not available in a browser and guessing would produce values that never exist at runtime. It also does not validate that a URL is a URL — that check belongs where the value is used.

For the same data as YAML, use the YAML converter; to spot the one key that differs between two environments, the text diff is faster than reading both files.

dotenv questions

How close is this to dotenv?

It follows the rules Node’s dotenv and Docker Compose implement: a leading export is ignored, an unquoted value ends at a whitespace-prefixed # comment, double-quoted values unescape \n, \r, \t, \" and \\, and single-quoted values are literal. Where the two tools disagree, the page shows the value it produced so you can check it.

Why warn about duplicates instead of erroring?

Because a duplicate is legal and the last value wins, which is exactly what happens at runtime. The problem is that the earlier value disappears without a trace, so it is listed as a warning and the surviving value is what appears in the JSON.

What happens to multi-line values?

A double-quoted value that spans lines stays one value, with the newlines kept — that is how people store a PEM key or a certificate in a .env file. An unclosed quote is an error, not a silent merge of the rest of the file.

Does this read my real .env file automatically?

No. There is no file-system access and no request; you paste the contents. That is deliberate, because a .env file is the most sensitive text a project has and it should not be handed to a web page by accident.

Are the values typed?

No — every value stays a string, because that is what the process receives. PORT=3000 becomes "3000", and quoting it in JSON is the honest representation. Convert types in your own loader, where the fallback rules live.

Related tools