About the Env to JSON Converter
Environment files and JSON configs hold the same kind of data in different clothes. This converter reads a .env file, with comments, export prefixes, single and double quotes and multi-line quoted values, and writes it as JSON. You can turn on type guessing so that true, 3000 and null become real JSON types, and nesting so that DB__HOST=localhost becomes {"db": {"host": "localhost"}}. The other direction turns a JSON object into .env lines, flattening nested keys with double underscores. Problems such as an invalid name or a missing quote are reported with the line number. Nothing leaves your browser, which matters for files full of secrets.
Updated October 2026
How to use the Env to JSON Converter
- 1Choose .env to JSON or JSON to .env.
- 2Paste your text on the left.
- 3Choose whether to guess types and whether __ means nesting.
- 4Read the result on the right.
- 5Copy it or download it.
From .env to JSON
Each KEY=value line becomes a property. Blank lines and lines starting with # are skipped. A leading export is removed, so shell-style files work. Values wrapped in double quotes may span several lines, which is useful for private keys, while single quotes keep everything exactly as typed.
JSON is better for typed configuration, and some platforms accept their settings only as JSON. With type guessing, DEBUG=true becomes a boolean and PORT=3000 a number, but a value like 007 stays text so leading zeros are not lost.
Environment variables are always strings in a running process, so type guessing is a convenience for JSON output, not how your program will see them. Keep that in mind when you move a setting between the two formats. A value written as 0123 stays text, and anything with letters is left alone, so only clear numbers and booleans are changed.
From JSON to .env
- Keys are written in capitals, with other characters replaced by underscores.
- Nested objects are joined with double underscores.
- Values with spaces or special characters are put in double quotes.
- Arrays are written as JSON text in one value.
- Null becomes an empty value.
Related tools
For other config formats, use the TOML to JSON Converter or the YAML to JSON Converter. Check the output with the JSON Validator, generate strong secrets with the Password Generator and encode binary secrets with the Base64 Encoder & Decoder. Keep real .env files out of version control.
Features
- Comments, export prefix and blank lines
- Single, double and multi-line quoted values
- Optional types: booleans, numbers, null
- Nesting from double underscores
- JSON to .env with quoting where needed
- Warnings for duplicates and $VARIABLE references
- Private, runs in your browser
Frequently asked questions
What is a .env file?
A plain text file of KEY=value lines that stores settings such as ports and API keys. Many frameworks load it into environment variables at startup.
How are quotes handled?
Double quotes allow escapes like \n, single quotes are taken literally and unquoted values end at a trailing comment that starts with a space and #.
Why did my number become a string?
Turn on the option that guesses types. Without it every value stays text, which is how environment variables really work.
What does nesting do?
With nesting on, two underscores split a name into levels: DB__HOST becomes db.host. Names are written in lower case in the JSON.
Does it expand ${VARIABLES}?
No. References are left as written and the tool warns you, because the values they point to may not be in the file.
Is it safe to paste secrets?
The conversion runs in your browser and nothing is uploaded. Even so, avoid pasting real production secrets into any website.
What happens with duplicate keys?
The last value wins, as in most loaders, and the tool lists the duplicates in a warning.