.env to JSON Converter
Paste a .env file to get clean, two-space-indented JSON, or flip the direction to turn a JSON object back into dotenv lines. Comments and blank lines are dropped, a single pair of surrounding quotes is stripped, and a leading export is handled. Your secrets stay in the browser and are never uploaded.
How to convert .env to JSON
- Choose a direction with the toggle: '.env to JSON' or 'JSON to .env'.
- Paste your .env text (or a JSON object) into the input box, or click 'Load sample' to try one.
- Watch the output box update live as you type; there is no run button.
- If a line is malformed, read the inline error and fix that line.
- Use 'Copy' to grab the result, or 'Download' to save it as env.json or .env.
Examples
Dotenv to JSON (comments, quotes and export)
# app configuration PORT=3000 NAME="My App" export TOKEN=abc123 DATABASE_URL=postgres://user:pass@localhost:5432/db DEBUG=true
{
"PORT": "3000",
"NAME": "My App",
"TOKEN": "abc123",
"DATABASE_URL": "postgres://user:pass@localhost:5432/db",
"DEBUG": "true"
}Value with an equals sign, plus an empty value
URL=postgres://a=b EMPTY=
{
"URL": "postgres://a=b",
"EMPTY": ""
}JSON to .env (spaces trigger quoting)
{ "PORT": "3000", "NAME": "My App" }PORT=3000 NAME="My App"
Frequently asked questions
Are my secrets uploaded anywhere?
No. The conversion runs entirely in your browser, so the values in your .env file never leave your device or get sent to a server. Nothing is logged.
How are comments and blank lines handled?
Lines whose trimmed text starts with # are treated as comments and dropped, and blank lines are ignored. Only KEY=value lines end up in the JSON output.
Does it support the export prefix?
Yes. A leading 'export ' (as in export KEY=value) is recognised and removed, so a line like export TOKEN=abc123 produces the clean key TOKEN with value abc123.
What about values that contain an equals sign?
The line is split on the first equals sign only, so everything after it is kept as the value. That means URL=postgres://a=b parses to the value postgres://a=b rather than being truncated.
How are quotes treated?
A single pair of matching surrounding single or double quotes is stripped from each value. So NAME="My App" becomes My App, while inner quotes and characters are left untouched.
Are numbers and booleans converted to real types?
No. Dotenv values are always strings, so PORT=3000 becomes the string "3000" and DEBUG=true becomes "true". This matches how process.env behaves at runtime.
What happens with a malformed line?
A non-comment line with no equals sign, or one with an empty key, is invalid, so the tool shows an inline error naming the offending line and produces no output until you fix it.
Can I convert JSON back into a .env file?
Yes. Switch the direction to 'JSON to .env' and the tool writes KEY=value lines. Any value containing a space, a #, a quote or edge whitespace is wrapped in double quotes with embedded quotes and backslashes escaped.
How are duplicate keys resolved?
When the same key appears twice, the last value in the file wins, which mirrors how most dotenv loaders behave. The earlier assignment is silently overwritten in the JSON output.
Learn more
- Dotenv Parsing Rules: Quotes, Export and Comments
How this parser handles KEY=value lines, comments, the export prefix, surrounding quotes, and values that contain an equals sign.
Related tools
INI to JSON
Convert INI config to JSON online. Paste an INI file and get clean, nested JSON with sections as objects. Runs entirely in your browser.
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
JSON to YAML
Convert JSON to YAML online. Paste JSON and get clean, readable YAML with 2-space indentation and no line wrapping. Fast, free and runs in your browser.
YAML to JSON
Convert YAML to JSON online. Paste YAML and get clean, pretty-printed JSON with the indentation you choose. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.