.env ↔ JSON Converter
Convert dotenv files to JSON and back, quotes and comments included.
100% in your browser — nothing uploadedConvert a .env file to JSON
About this .env to JSON converter
Paste the contents of a .env file and get a clean JSON object, or paste JSON and get a valid .env back. The parser understands real dotenv syntax: export prefixes, full-line and inline comments, single quotes (kept literal) versus double quotes (which expand \n, \t, and \" escapes), empty values, and duplicate keys — the last one wins, with a warning. Invalid lines are reported with their line numbers so you can fix them fast.
Going the other way, strings, numbers, and booleans are written as .env values and only quoted when they need it — spaces, #, =, or line breaks. Nested objects aren’t valid in a .env file, so the tool either lists the offending keys or, with one checkbox, flattens them into uppercase DB__HOST-style keys. Environment files are exactly where API keys and database passwords live, so everything runs locally in your browser: your secrets never leave your device.
FAQ
Is it safe to paste a .env file with real secrets?
Yes. The conversion runs entirely in your browser — there is no upload, no server, and no logging. Your variables never leave your device, which is the whole point for files full of API keys and passwords.
How are quotes and escapes handled?
Single-quoted values stay literal, while double-quoted values expand \n, \t, and \" escapes — the same rules popular dotenv loaders use. A quoted value can’t span multiple lines: write line breaks as \n inside double quotes. When generating .env output, values are only quoted when they contain spaces, #, =, or line breaks.
What happens to nested JSON objects?
A .env file is flat, so nested objects and arrays can’t be written directly. By default the tool reports which keys are nested; enable "Flatten nested keys with __" to turn { "db": { "host": … } } into DB__HOST — a convention many config libraries read back automatically.