.env ↔ JSON Converter

One input per line. Output is numbered to match the input order.
Pinned tools are listed in your favourites on the home page.Copies a link to this tool that carries your current input, so it opens ready to run.Gives you an iframe snippet for putting this tool on your own site.
Ctrl+Enter Run  · Ctrl+Shift+C Copy  · Esc Clear

Understand .env ↔ JSON Converter

This converter turns a .env file into a JSON object and a JSON object back into .env lines.

How it works

Reading a .env file, each line is split at its first = sign, blank lines and lines beginning with # are skipped, and one layer of matching surrounding quotes is removed from the value. Every value arrives as a JSON string because .env has no types, so PORT=3000 becomes "3000" rather than 3000. Going the other way, nested JSON objects are flattened with a double underscore — {"db":{"host":"localhost"}} becomes db__host=localhost — and any value containing a space, an =, or a # is quoted.

When to use it

  • Moving local .env settings into a deployment platform or CI secret store that accepts JSON.
  • Reading a long .env file as structured data so you can diff it against another environment.
  • Producing a .env file from a JSON config block a service handed you.
  • Checking whether a value containing spaces or a # is quoted the way you assumed.

Watch out for

  • Every value is a string. If your code expects a number or a boolean out of the JSON side, convert it there — "false" is a truthy string.
  • Nesting flattens with a double underscore, not a dot. A JSON object {db:{host:x}} becomes DB__HOST=x, because a dot is not portable across shells and loaders. Converting back rebuilds the nesting from the same separator.
  • Comments only work on their own line. PORT=3000 # dev keeps "3000 # dev" as the value, which is also how several .env loaders behave.
  • Variable references are not expanded — ${DB_HOST} stays as literal text.

Not the right tool for: Handling live production credentials. Everything here runs in your browser and nothing is uploaded, but a file full of real keys still should not be pasted into a tab you might screen-share.

Frequently Asked Questions

What .env syntax is supported?

KEY=value pairs, values wrapped in single or double quotes, # comment lines, blank lines, and the export KEY=value form used in shell-sourced files. The export prefix is stripped from the key. Values are taken literally — ${VAR} references are not expanded, and surrounding quotes are removed.

How are nested objects represented in .env?

This converter uses a double underscore. Nested JSON such as {"DB":{"HOST":"localhost"}} becomes DB__HOST=localhost, the separator ASP.NET Core, Symfony, and many Docker setups already understand. Converting the other way does not rebuild nesting: DB__HOST stays a flat key, because .env has no native concept of nesting.

When would I convert .env to JSON?

Useful when deploying to systems that consume JSON config (AWS Lambda environment, some CI/CD platforms), when using libraries that read JSON config files (cosmiconfig), or when sharing config with tools that cannot parse .env syntax.

How to Use .env ↔ JSON Converter

  1. Paste or type your input in the input area above.
  2. The tool processes your input automatically or click Run.
  3. Copy or download the result using the action buttons.
  4. Use Ctrl+Enter to run quickly from the keyboard.