.env to JSON Converter
Convert a .env file to JSON, or a flat JSON object
back to .env format. Because .env files
routinely hold real passwords, API keys, and tokens, everything
here runs in your browser — nothing you paste is ever sent
anywhere.
Values stay honest strings — no silent guessing
A .env file has no type system: everything after
the = is plain text. This tool respects that
instead of trying to be clever — DEBUG=true becomes
the JSON string "true", not the boolean true, and PORT=8080 becomes the string "8080", not a number. If your code needs real
booleans or numbers, that conversion happens deliberately in your
code, not silently in this tool.
Worked example: .env → JSON
Input:
# Database config DB_HOST=localhost DB_PASSWORD="p@ss w0rd" DEBUG=true EMPTY_VAL=
converts to:
{
"DB_HOST": "localhost",
"DB_PASSWORD": "p@ss w0rd",
"DEBUG": "true",
"EMPTY_VAL": ""
}
The comment line disappears, DB_PASSWORD's
surrounding quotes are stripped (leaving the space inside
intact), and DEBUG stays the string "true" rather than becoming a boolean.
Worked example: JSON → .env
Input:
{
"DB_HOST": "localhost",
"DB_PASSWORD": "p@ss w0rd",
"DEBUG": true,
"PORT": 8080
} converts to:
DB_HOST=localhost DB_PASSWORD="p@ss w0rd" DEBUG=true PORT=8080
DB_PASSWORD gets wrapped in quotes because its
value contains a space; the others don't need quoting, so
they're written bare to keep the file easy to read.
Frequently asked questions
Why does DEBUG=true come out as the JSON string "true", not the boolean true?
Because that's what it actually is. A .env file has no type system — every value on the right of the = is plain text, so DEBUG=true and DEBUG=yes are equally just the three or four characters that follow the equals sign. This tool never guesses that a value "looks like" a boolean or a number and silently converts it; DEBUG=true becomes the JSON string "true", and PORT=8080 becomes the string "8080", not the number 8080. If your application needs real booleans or numbers, convert them explicitly in code after parsing — that's a decision this tool deliberately leaves to you instead of guessing.
What's the difference between how quoted and unquoted values are handled?
Double-quoted values ( KEY="like this" ) get backslash-escapes unescaped — \n becomes an actual newline, \" becomes a literal quote, and \\ becomes a single backslash — matching the standard dotenv convention. Single-quoted values ( KEY='like this' ) and unquoted values are taken completely literally: no escape processing happens at all, so a backslash in KEY=C:\path stays exactly as two characters, a backslash and a "p". Only double quotes trigger unescaping.
What happens if my JSON has a nested object or an array value when converting to .env?
.env files are flat by nature — every line is KEY=VALUE, with no way to represent structure. Rather than silently invent a flattening scheme you didn't ask for (like turning {"db": {"host": "x"}} into DB_HOST=x), this tool rejects the conversion and names the exact key holding the nested value, so you can flatten it yourself the way that makes sense for your project — or remove it.
Is my .env file uploaded anywhere? It has real passwords in it.
No — and this matters more here than almost anywhere else on the site. .env files routinely hold database passwords, API keys, and tokens. Parsing in both directions happens entirely in your browser with plain JavaScript string processing; nothing you type or paste is ever sent to a server, saved, logged, or included in any analytics. Closing the tab clears everything.
How does this decide whether to wrap a value in quotes when converting JSON to .env?
A value is wrapped in double quotes only when it contains whitespace or one of the characters " ' # \ — anything that would otherwise make the line ambiguous to read back. Inside those quotes, a literal backslash or double quote is escaped so the result is valid to re-parse. Plain values like true, 8080, or localhost are written bare, since quoting them would add nothing but visual noise.
Does this skip comments and blank lines in my .env file?
Yes. Blank lines and any line whose first non-whitespace character is # are skipped entirely when converting .env to JSON, matching how every real dotenv loader treats them. A line with no = sign at all is skipped too, rather than guessed at.