.env ↔ JSON Converter
Convert a .env file to flat JSON and back, plus an optional YAML export. Your data never leaves your browser.
Input
Output
What is .env ↔ JSON Converter?
A .env file stores configuration and secrets as plain KEY=value lines, and is read by libraries like Node's dotenv in almost every JavaScript, Python and Ruby project. This tool converts a .env file to flat JSON (handy for feeding config into a script, a CI variable list, or a debugging session) and back again, plus an optional export to YAML for tools that expect a config map in that format.
How to use .env ↔ JSON Converter
- Choose a direction: .env → JSON or JSON → .env.
- Paste your content into the Input panel (or click Example to load a sample).
- The Output panel converts it instantly; any parsing notes (duplicate keys, skipped lines, literal
$VARreferences) appear below it. - Use Copy or Download to grab the result, or YAML to export the same data as a
.yamlfile.
How .env parsing works
This tool follows the same parsing rules as the real dotenv npm package (verified directly against its source and test suite, not guessed), since that's the library most projects actually use to read a .env file:
// .env in
export APP_NAME="Café Résumé"
PORT=3000
GREETING=hello world # not part of the value
DATABASE_URL='postgres://user:pass@localhost/db'
// JSON out
{
"APP_NAME": "Café Résumé",
"PORT": "3000",
"GREETING": "hello world",
"DATABASE_URL": "postgres://user:pass@localhost/db"
}
A few specific rules worth calling out because they trip people up: an export prefix is stripped but still a valid assignment. Single-quoted values are 100% literal (no escapes at all). Double-quoted values only unescape \n and \r — \t and other backslash sequences are left untouched. For an unquoted value, a # anywhere starts a trailing comment — even with no space before it — so GREETING=hi#bye parses to just hi; wrap the value in quotes if it needs a literal #. A duplicate key keeps its last value, matching dotenv exactly. And ${OTHER_VAR} / $OTHER_VAR references are not expanded — base dotenv never interpolates variables (only the separate dotenv-expand package does), so this tool keeps them as literal text and flags them in Notes.
Frequently asked questions
Is it safe to paste real secrets or API keys here?
Yes. All parsing happens in your browser using plain JavaScript; nothing is ever sent to a server. That said, treat any tool cautiously with production secrets and prefer a throwaway/example file when possible.
Does a # in the middle of a value always start a comment?
Yes, for unquoted values — matching the real dotenv library, a # anywhere in an unquoted value starts a comment, even with no space before it. Wrap the value in single or double quotes if it needs to contain a literal #.
Does this tool expand ${OTHER_VAR} references?
No. Base dotenv does not interpolate variables — that behavior only exists in the separate dotenv-expand package — so this tool keeps $VAR and ${VAR} as literal text, matching dotenv's default behavior.
What happens with a duplicate key or non-ASCII characters?
A duplicate key keeps its last value, same as dotenv, and the earlier one is flagged in Notes. Accented characters and other non-ASCII text pass through untouched.