🔑 .env to JSON Converter
Paste a .env file and get JSON: each KEY=value line becomes a property, with quotes, export and comments handled.
5 variable(s)
How the .env to json converter works
A .env file (the dotenv format) is a list of KEY=value pairs your app loads as environment variables. The converter reads each line, drops an optional leading export, and takes everything after the first = as the value. Double-quoted values are unwrapped and their \n, \t and \" escapes expanded; single-quoted values are kept literally; unquoted values have any trailing # comment trimmed. Lines starting with # and blank lines are skipped. The result is a flat JSON object mapping each variable name to its string value.
This is useful for feeding a .env into tooling that expects JSON, for inspecting exactly what a dotenv file defines, or for diffing two environments. A word of caution: .env files usually contain secrets (API keys, database passwords, tokens), which is precisely why this tool runs entirely in your browser — nothing is uploaded, logged or stored, and it works offline. Treat the JSON output as equally sensitive.
Frequently asked questions
How do I convert a .env file to JSON?
Paste the file contents or load a .env file and the tool outputs a flat JSON object where each environment variable is a property. Copy or download the JSON.
Does it handle quotes and the export keyword?
Yes. A leading "export " is ignored, double-quoted values are unwrapped with \n/\t/\" escapes expanded, and single-quoted values are taken literally without expansion — matching how dotenv loaders behave.
Are comments removed?
Lines starting with # are skipped entirely, and an unquoted value with a trailing # comment has the comment trimmed. Comments inside a quoted value are kept as part of the value.
Are values typed or all strings?
All values are strings, because environment variables are strings by definition — DEBUG=true becomes "true". Convert to boolean or number in your code if needed.
Is it safe to paste secrets here?
The conversion runs entirely in your browser and nothing is sent anywhere, so it never transmits your keys. Still, treat both the input and the JSON output as sensitive and avoid pasting production secrets into any tool you don't control the machine for.