dotenv to JSON Converter
Convert a .env file to a JSON object and JSON back to .env, right in your browser. Your environment variables stay local.
The dotenv to JSON converter runs entirely in your browser. The .env files, JSON, and secrets you paste never leave your device and nothing is uploaded to ArrayKit.
Open the JSON Formatter
About dotenv to JSON
The dotenv to JSON converter reads a .env file — the KEY=value format that dotenv, docker-compose, and most 12-factor apps use — and turns it into a clean JSON object you can drop into a config, a secret manager, or a CI variable set. It understands single- and double-quoted values, ignores blank lines and '#' comments, strips an optional 'export ' prefix, and unescapes sequences like \n inside double quotes. Flip the toggle to go the other way and JSON becomes a valid .env file, with any value containing spaces or a '#' automatically double-quoted so it parses correctly. It is built for developers wiring up environments, rotating secrets, or reviewing what a config actually contains. Everything runs on your device — your environment variables never leave the browser.
Features
- Convert a .env file to a flat JSON object in one paste
- Turn a JSON object back into a valid .env file
- Handles single-quoted, double-quoted, and bare values
- Skips blank lines and full-line or inline '#' comments
- Strips an optional 'export ' prefix on each key
- Double-quotes JSON values with spaces or '#' so .env re-parses
- Unescapes \n, \t, and \" inside double-quoted values
- Runs entirely in your browser with no variables uploaded
How to use the dotenv to JSON
- Keep '.env → JSON' selected and paste your .env file
- Copy the JSON object or download it as env.json
- Switch to 'JSON → .env' to reverse the conversion
- Paste a JSON object and copy the generated .env text
Example
Input
export PORT=3000
APP_NAME="My Service"
DEBUG=false # verbose
Output
{
"PORT": "3000",
"APP_NAME": "My Service",
"DEBUG": "false"
}
The 'export ' prefix and inline comment are stripped; the quoted value is preserved.
Common errors & troubleshooting
- A value with a space or '#' loses part of itself after converting to .env. — That is why the converter double-quotes such values automatically. If you hand-edit the .env, wrap the value in double quotes so dotenv reads it whole.
- 'JSON → .env' reports the JSON must be a single object. — A .env file is a flat set of key/value pairs, so the input must be one JSON object — not an array and not a top-level string or number.
- An inline '# comment' disappears from an unquoted value. — In .env, '#' after a value starts a comment. Wrap the value in quotes if the '#' is part of the data, e.g. SECRET="a#b".
- Numbers and booleans come out quoted in the JSON. — Environment variables are always strings, so the converter keeps every value as a JSON string to match how your app will read them.
Frequently asked questions
- How does the dotenv to JSON converter handle quotes in a .env file?
- Double-quoted values are unescaped (so \n becomes a newline) while single-quoted values are kept literal. Either kind lets a value hold spaces, '=', or '#' without being cut short. The surrounding quotes are removed in the JSON output.
- What happens to comments and the export prefix when I convert .env to JSON?
- Full-line '#' comments and blank lines are skipped, and an inline '# comment' after an unquoted value is dropped. A leading 'export ' on a key is stripped so the JSON key is just the variable name.
- Why are all my values strings in the JSON output?
- Environment variables are strings by definition — PORT=3000 is the text "3000", not the number 3000. The converter preserves that so the JSON matches exactly what process.env would return in your app.
- How does JSON to .env decide when to add quotes?
- Any value containing a space, '#', or a quote character is wrapped in double quotes, with special characters escaped, so the resulting .env line parses back to the original value. Simple tokens are left unquoted.
- Can I convert a JSON config that has nested objects into a .env file?
- A .env file is flat, so nested objects and arrays are JSON-stringified into a single quoted value. For a true flat file, flatten your JSON to top-level string values before converting.
- Are my environment variables and secrets uploaded anywhere?
- No. The dotenv to JSON converter runs entirely in your browser. The .env text and JSON you paste never leave your device and are not sent to ArrayKit or any server.
Related tools
All ArrayKit tools