JSON to .env converter
Config often starts life as a JSON object but has to be deployed as a .env
file of environment variables. This tool converts a JSON configuration
object into dotenv KEY=value lines, handling the flattening and quoting rules
so the result drops straight into a .env file.
How it works
The converter flattens the object to a single level and formats each leaf as a line:
- Nested objects are flattened with underscores, so
{"API": {"KEY": "x"}}becomesAPI_KEY=x. - Arrays and remaining objects are serialised back to compact JSON and quoted.
- Quoting: a value is wrapped in double quotes whenever it contains
whitespace, a
#, an=, a quote or a newline, or is empty. Plain numbers and booleans are written unquoted, matching how dotenv parsers expect values.
Example
This JSON:
{ "API": { "KEY": "ab cd" }, "PORT": 3000, "DEBUG": true }
converts to:
API_KEY="ab cd"
PORT=3000
DEBUG=true
API.KEY flattened to API_KEY, the value with a space was quoted, and the
number and boolean were left unquoted.
Everything runs in your browser — your configuration never leaves your device.