Env to JSON Converter
Convert .env files to JSON instantly. Handles quoted values, comments, escape sequences, and type coercion. Free, runs in your browser, no signup.
What this does
Takes a .env file (the kind dotenv reads, the kind you check into .env.example, the kind your Docker container loads at boot) and turns it into a JSON object. Useful when you need to feed config into a tool that wants JSON — Kubernetes ConfigMaps, AWS SSM Parameter Store, GitHub Actions inputs, Terraform tfvars, or just a quick visual sanity check that your .env parses the way you think it does.
The parser handles the cases people actually hit:
- Quoted values —
KEY="some value with spaces"works. Single quotes preserve literally; double quotes process\n,\t,\",\\escape sequences. - Comments — full-line comments (
# comment) are skipped. Inline comments after unquoted values (KEY=value # note) are stripped from the value. exportprefix —export KEY=valueis treated likeKEY=value. Bash compatibility.- Type coercion (optional) — when on,
true/false/nulland pure-numeric strings become their JSON-typed equivalents instead of remaining strings. Off by default for unquoted values where you may want strings preserved (e.g., a port"8080"you’ll concat into a URL).
Common gotchas it does NOT do (deliberately):
- Variable interpolation (
KEY=${OTHER_KEY}) — dotenv tools differ on this; we don’t expand. Paste already-resolved values. - Multiline values — pure spec dotenv doesn’t support these. If you have multiline secrets, base64-encode them first.
Real use cases
- Kubernetes ConfigMap migration. You have a
.envfor a Docker container; you need a ConfigMap entry. Paste in, copy JSON, embed underdata:. - GitHub Actions
--env-fileto inputs. Action inputs want JSON-shaped objects; your repo has a.env. Convert once, paste into workflow. - Terraform
tfvars. Your dev environment is in.env; yourterraform planwants--var-file=*.tfvars.json. Convert. - AWS SSM Parameter Store seeding. You need to write a hundred KEY=value pairs into Parameter Store. Convert to JSON, then loop the keys with
aws ssm put-parameter. - Sanity check. “Does my
.envactually parse?” Paste in. If keys are missing from the JSON, your file is malformed.
How parsing decisions work
For each non-empty, non-comment line:
- Match
[export ]KEY=value. If it doesn’t match, the line is reported as an error (line number included). - If the value starts and ends with the same quote (
"..."or'...'), strip them. Apply escape unescaping for double quotes. - If unquoted, trim trailing whitespace, then strip inline comments at the first
#(space-hash) sequence. - If type coercion is on, check if the string equals
true,false,null, or matches^-?\d+(\.\d+)?$. Convert if so. - Assign
out[key] = value. Duplicate keys overwrite (last wins, same as dotenv).
Errors are reported below the input area but don’t abort the conversion — valid lines still appear in the output. This is intentional: when you paste a half-broken file you want to see what does work, not just a “syntax error” message.
Privacy
The tool runs entirely in your browser. The textarea contents never leave your machine — no fetch, no analytics, no telemetry. You can verify by opening DevTools → Network tab and converting; you’ll see zero network requests fire.