JSON to Env Converter
Convert a JSON object to .env KEY=VALUE format, with nested-object flattening and comment reinsertion. Client-side only.
Paste a JSON object and this tool converts it into .env KEY=VALUE format instantly in your browser. Nested objects are flattened into dotted keys (or kept as-is if you disable nesting), and any $comments field produced by the Env to JSON converter is reinserted as # comment lines above the matching key. Nothing is uploaded — the conversion runs entirely client-side.
About the JSON to Env Converter
This is the reverse of Env to JSON: it takes a JSON object — flat or nested — and writes it out as plain .env text that a process manager, Docker Compose file, or shell can source directly. Nested objects like { "app": { "cache": { "ttl": 60 } } } become dotted keys such as APP.CACHE.TTL=60 when dotted-key flattening is on; turn it off to require already-flat keys. If the JSON includes a $comments object (as produced by pasting output from Env to JSON), each entry is written back as a # comment line directly above its key, so a round trip through both tools keeps your documentation intact.
You May Also Need
Paste a JSON object and this tool converts it into .env KEY=VALUE format instantly in your browser. Nested objects are flattened into dotted keys (or kept as-is if you disable nesting), and any $comments field produced by the Env to JSON converter is reinserted as # comment lines above the matching key. Nothing is uploaded — the conversion runs entirely client-side.
How to convert JSON to .env
- 1
Paste your JSON object
Enter a JSON object into the input panel, or click the flask icon to load a sample with a nested object.
- 2
Choose flattening and comment behavior
Open Advanced options to set the dotted-key separator or disable flattening, and to choose whether a $comments field is written back as # comment lines or ignored.
- 3
Click Convert
The JSON is flattened (if enabled) and each entry is written as a KEY=VALUE line, with comments reinserted above their key when present.
- 4
Copy or download the .env file
Copy the output or download it as a .env file ready to drop next to your project. Use the switch-direction icon to jump back to Env to JSON.
References
- The Twelve-Factor App — Config
The methodology behind storing configuration as environment variables, which this converter's output format follows.
- dotenv (motdotla) — README
The reference implementation for .env file syntax, describing how KEY=VALUE pairs and comments are conventionally written.
- RFC 8259 — The JSON Data Interchange Format
The IETF specification for the JSON input format this tool parses.
Related developer tools
Env to JSON
Convert a .env file into JSON, with type inference, nested keys, and comment preservation.
JSON to Properties
Convert a JSON object into Java .properties format, the equivalent flow for properties files.
JSON Formatter
Paste raw JSON and instantly get a formatted, syntax-highlighted, validated view before converting it.
YAML to JSON
Convert between YAML and JSON configuration formats.
JSON to Env FAQ
- How do I convert JSON to a .env file online?
- Paste a JSON object into the input panel and click Convert. Each top-level key becomes a KEY=VALUE line; nested objects are flattened into dotted keys by default. Copy the result or download it as a .env file.
- Can I convert a nested JSON object to .env format?
- Yes. With "Dotted keys → nested" enabled, a nested object such as { "db": { "host": "localhost" } } is flattened to DB.HOST=localhost. Disable the toggle to only accept already-flat JSON objects.
- Will my JSON be uploaded anywhere when converting to .env?
- No. All parsing and formatting happens locally in your browser via JavaScript. This matters since .env output commonly contains secrets such as API keys or database passwords.
- How are booleans and numbers written out in the .env output?
- JSON booleans and numbers are written as their plain text form — true, false, or the number itself — matching how the Env to JSON converter reads them back with type inference enabled.
- Does JSON to Env support comments?
- If your JSON has a $comments object (for example, pasted directly from Env to JSON's output), each entry is reinserted as a # comment line above the matching key. Set Comments to "Ignore" in Advanced options to skip this and emit plain KEY=VALUE lines only.
- What separator is used when flattening nested JSON keys?
- The default separator is a dot (.), matching common env-var naming conventions like DB.HOST. You can change it in Advanced options — for example to an underscore to produce DB_HOST instead.
- Can I use this to generate a .env file for Docker or Node.js?
- Yes. The output is standard KEY=VALUE text compatible with dotenv, Docker Compose's env_file, and most process managers that read .env files at startup.