.env to JSON
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.
How to convert a .env file to JSON
- Paste the contents of your
.envfile, or drop the file onto the input pane. - Choose whether to expand nested keys. With
__selected,DB__HOSTbecomes{"DB": {"HOST": …}}. - Tick Lowercase key names if the JSON consumer expects lowercase config keys.
- Leave type inference on so ports and flags come out as numbers and booleans.
- Copy or download the JSON.
What the parser handles
export KEY=value— the prefix is stripped so shell-style files work.- Double-quoted values — unwrapped, with
\n,\r,\"and\\un-escaped. - Single-quoted values — unwrapped literally, with no escape processing, matching shell semantics.
- Unquoted values — trimmed, and a trailing
#comment is removed. - Comment and blank lines — skipped.
- Lines with no
=— skipped rather than treated as an error.
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.