ENV to JSON Converter
100% private — runs on your device, never uploaded. Works offline once loaded.
Paste a .env file to get a clean JSON object, or paste a JSON object to generate .env lines. Comments, quoted values, and export prefixes are handled correctly, all locally in your browser.
Two conversions in one tool
A .env file is a flat list of KEY=VALUE lines used to configure applications outside of source code. This tool converts that format into a JSON object — handy for feeding config into a script, a JSON-based settings store, or a viewer — and converts a JSON object back into .env lines when you need to hand configuration to a tool that reads dotenv. Every value in a .env file is fundamentally a string, so the JSON side is always an object of string values.
How the .env parser works
Parsing follows the conventions the popular dotenv libraries use. Blank lines and lines beginning with # are ignored. An optional export keyword at the start of a line is stripped. The key is everything before the first =, trimmed. The value is everything after, with a few rules applied so it matches real runtime behaviour.
- Double-quoted values interpret escapes such as
\n,\t, and\" - Single-quoted values are taken literally, so
$VARstays as text - Unquoted values have a trailing
#inline comment stripped and are trimmed - A line with no
=is skipped rather than throwing
How JSON is turned back into .env
Converting the other way, each top-level key becomes a KEY=VALUE line. String values are emitted bare when they are safe, and wrapped in double quotes when they contain spaces, #, quotes, =, or leading/trailing whitespace — with the necessary characters escaped so the file round-trips cleanly. Numbers and booleans are written as their literal text, null becomes an empty value, and nested objects or arrays are serialised as a quoted JSON string, since .env has no concept of nesting.
When to use it
Reach for this when moving configuration between systems that speak different formats: exporting a .env for review as structured JSON, seeding a local .env from a JSON secrets export, or simply reading a messy env file more clearly. Because it runs entirely in the browser, it is safe to paste real configuration — including secrets — without them ever being transmitted.
Frequently asked questions
Are the values typed, or all strings?
When parsing .env to JSON every value is a string, because that is what a .env file stores. DEBUG=true becomes the string "true", not a boolean.
How are inline comments handled?
For unquoted values, a # preceded by whitespace and everything after it is treated as a comment and removed. Inside quotes, # is kept as part of the value.
What happens to nested JSON when converting to .env?
Objects and arrays are stringified to JSON and stored as a single quoted value, since .env files are flat key/value pairs with no nesting.
Does it preserve the order of keys?
Yes — keys are emitted in the order they appear in the source, in both directions.
Can I paste values that contain equals signs?
Yes. Only the first = on a line splits key from value, so DATABASE_URL=postgres://a=b works as expected.
Is it safe to paste secrets?
Yes — everything is processed locally in your browser and nothing is uploaded, so credentials stay on your device.
Advertisement