🗝️ JSON to .env Converter
Paste a JSON object and get a .env file: each property becomes a KEY=value line, quoted when it needs to be.
flat keys → KEY=value lines
How the json to .env converter works
The tool parses your JSON object and writes one KEY=value line per property. Values that are safe (no spaces, quotes, #, = or newlines) are written bare; anything else is wrapped in double quotes with its special characters escaped, so the file re-parses correctly. Numbers and booleans are written as their text form. The JSON must be a flat object, environment variables are a flat namespace, so nested objects are serialized to JSON strings rather than expanded. Walking the sample: DB_HOST=localhost is written bare, while GREETING="hello world" is quoted because the value contains a space that a dotenv loader would otherwise treat as the end of the value. The quoting rule mirrors how loaders parse the file, so the .env round-trips through the .env-to-JSON tool to the same values.
This helps you turn a configuration object into a .env file for Docker, a CI secret store, or local development. Because dotenv variables are a flat list, keep your JSON one level deep for a clean file. As with any environment file, the values are often secrets. This runs entirely in your browser so nothing is uploaded, and you should store the resulting .env securely and keep it out of version control.
Frequently asked questions
How do I convert JSON to a .env file?
Paste a flat JSON object or load a .json file and the tool outputs KEY=value lines. Copy the result or download it as a .env file for your app, Docker or CI.
When are values quoted?
A value is wrapped in double quotes when it contains a space, quote, #, =, or newline, otherwise it's written bare. Special characters inside quotes are escaped so the line parses back to the same value.
What happens to nested objects or arrays?
Environment variables are a flat namespace, so a nested object or array is serialized to a JSON string and stored as one quoted value. For a clean .env, keep the JSON one level deep.
Are the keys changed?
No, property names are used verbatim as the variable names. If you follow the usual convention of UPPER_SNAKE_CASE keys in your JSON, that's exactly what you'll get in the .env.
Why is one value quoted and another not?
A value is only quoted when it must be, when it contains a space, quote, #, = or newline that would otherwise confuse a dotenv parser. localhost is written bare; hello world is written as "hello world". Bare values keep the file tidy while quoting protects the ones that need it.
Are booleans and numbers written with quotes?
No, DB_PORT=5432 and DEBUG=true are written unquoted as plain text, since environment variables are strings anyway. When your app reads them back it receives the strings "5432" and "true", which you convert to a number or boolean in code.
Is my JSON uploaded?
No, everything runs locally in your browser, which matters because .env files typically hold secrets. Nothing is transmitted and it works offline.