JSON to .env
Turn a nested JSON configuration into ready-to-paste .env file lines, the way 12-factor configs expect. Top-level keys become uppercase variable names and nested objects join with the Cloud-Run style double underscore (SERVER__HOST=localhost). Strings that need it are quoted, arrays and objects are kept as JSON values, numbers and booleans stay bare, and a sorted option makes diffs easier. Everything runs on your device.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
What it produces
Paste a JSON object and get one .env line per leaf value. Top-level keys become variable names; nested objects are flattened by joining the path with a separator, so {"server":{"host":"x"}} becomes SERVER__HOST=x. Arrays and objects at a leaf stay as single-line JSON, numbers and booleans stay bare, and null becomes an empty value.
The separator and naming options
The separator changes how a path is joined: __ (SERVER__HOST, the Cloud Run style), . (SERVER.HOST) or _ (SERVER_HOST), so pick whatever your runtime flattens to. Uppercase controls whether the final variable name is capitalised; with it off, keys keep their original case.
Quoting rules
Quoting is applied only where a plain value would break in a shell: a string containing a space, #, quote, backslash or newline is wrapped in double quotes and escaped, while simple tokens stay bare. Turning quoting off emits every string exactly as typed.
Limits, errors and privacy
Input is capped at one million characters and nesting at 128 levels, each with a clear error rather than a hang, and the top level must be an object. The flattening is pure string work in this tab with no upload, so configuration that holds credentials stays on your device.
Questions
How are nested objects flattened?
Nested keys join the parent with a double underscore by default, so { "server": { "host": "x" } } becomes SERVER__HOST=x. You can switch the separator to dot or single underscore.
What happens to arrays and objects?
Arrays are kept as JSON on one line (JSON.parse reconstructs them). Objects are flattened with the separator — { "server": { "host": "x" } } becomes SERVER__HOST=x. Null becomes an empty value.
Do strings always get quoted?
Only when they need it — values containing spaces, #, a quote or a newline are wrapped in double quotes with the contents escaped. Plain tokens stay bare so they behave predictably in shells and tools.
Related tools
See category.env <-> JSON
Parse a .env file into JSON, or turn a JSON object into .env text. Runs entirely on your device.
Flatten JSON
Flatten nested JSON to dotted keys (users.0.name) or collapse dotted keys back into nested JSON.
YAML to JSON
Convert YAML to JSON locally, with indent choice and optional key sorting.
Properties Converter
Convert Java .properties config to JSON or serialize JSON back to .properties.