jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

.env to JSON

dotenv lines → JSON object · updated 28 July 2026

Parse a .env file into JSON. export prefixes and # comments are stripped, quoted values are unwrapped and un-escaped, and keys using __ can be expanded back into nested objects. Values are strings in the file, so type inference turns 5432 back into a number.

Paste input to start.

How to convert a .env file to JSON

  1. Paste the contents of your .env file, or drop the file onto the input pane.
  2. Choose whether to expand nested keys. With __ selected, DB__HOST becomes {"DB": {"HOST": …}}.
  3. Tick Lowercase key names if the JSON consumer expects lowercase config keys.
  4. Leave type inference on so ports and flags come out as numbers and booleans.
  5. Copy or download the JSON.

What the parser handles

Privacy

Nothing is uploaded. The conversion runs in this tab using your own browser's JavaScript engine — no server sees your data, and the page keeps working with the network disconnected.

FAQ

Are variable references like ${OTHER} expanded?

No. Interpolation is a feature of some dotenv libraries and not others, and expanding it here would give you a file that behaves differently from the one your app loads. References are kept as literal text.

Why did my value lose its trailing comment?

An unquoted value ends at a # preceded by whitespace, which is how most dotenv parsers behave. Quote the value if the # is part of the data.

Is this safe for real secrets?

The parsing happens in your browser and nothing is transmitted. But be careful about pasting production secrets into any tool, and clear the pane when you are done.