UTILS.
100% in-browser
🔑

.env ⇄ JSON Converter

Convert a .env file to a JSON object or turn JSON back into KEY=value .env lines, entirely in your browser.

output

About this tool

.env ⇄ JSON Converter is a free, in-browser tool that turns environment-variable files into JSON and back again. Paste a .env file to get a tidy JSON object, or paste a JSON object to get KEY=value lines ready for a .env file. Everything is parsed locally in your browser — nothing is uploaded, and it uses JSON.parse only, never eval.

Going .env → JSON, it reads the file line by line: blank lines and # comments are skipped, a leading "export " is dropped, each line is split on its first = into a key and value, one layer of surrounding single or double quotes is trimmed from the value, and the result is serialized with JSON.stringify(obj, null, 2). Going JSON → .env, it parses the object and emits one KEY=value line per property; values containing spaces or special characters (or empty values) are wrapped in double quotes with backslashes, quotes and control characters escaped.

Use it to migrate config between formats, to inspect a messy .env as structured JSON, or to generate a .env from a settings object. The key count is shown so you can confirm nothing was dropped, and invalid JSON is reported rather than silently mangled.

Frequently asked questions

How are comments and quotes handled going from .env to JSON?
Blank lines and lines beginning with # are ignored, and a leading "export " is removed. Each remaining line is split on its first = sign, and if the value is wrapped in matching single or double quotes, one outer layer of those quotes is stripped.
When are values quoted going from JSON to .env?
Simple values are written bare as KEY=value. Values that contain whitespace, #, =, quotes or other special characters — or that are empty — are wrapped in double quotes, with backslashes, double quotes, newlines and tabs escaped so the line round-trips cleanly.
Does it use eval to parse JSON?
No. Parsing uses the built-in JSON.parse only, and output uses JSON.stringify. There is no eval or Function anywhere, so the tool is safe under a strict content-security policy and cannot execute pasted input.
What happens with invalid JSON or my data privacy?
Invalid JSON in JSON → .env mode shows an error instead of producing broken output. All conversion happens in your browser, so your keys, tokens and secrets are never uploaded or stored anywhere.

More tools