ENV to JSON converter

Paste the contents of a .env file to get JSON, or switch direction and paste a flat JSON object to get .env lines. Comments, an export prefix, quotes and escapes are understood. Everything runs in your browser, so secrets stay on your device.

Direction
Indent

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Choose the direction.
  2. Paste the input. For ENV → JSON, comments and blank lines are skipped.
  3. Pick indentation, and optionally type conversion (ENV → JSON) or the export prefix (JSON → ENV).
  4. Copy the result.

How values are read

# database
export HOST=localhost # local
MSG="line one\nline two"
RAW='no \n escapes here'

HOST is localhost (the inline comment is cut), MSG contains a real line break, and RAW keeps the backslash text as written.

Example

A=1, B=true and an empty C= give {"A":"1","B":"true","C":""}, or {"A":1,"B":true,"C":""} with type conversion.

Tips

  • A # without a space before it, as in a URL fragment, stays part of the value.
  • Different libraries differ on edge cases such as variable expansion (${OTHER}); this tool does not expand variables.

Frequently asked questions

Which .env rules are supported?

Lines of KEY=value, comment lines starting with #, an optional export prefix, double-quoted values with \n, \t, \r, \" and \\ escapes (also spanning lines), single-quoted values taken literally, and unquoted values that end at a space followed by #. If a key appears twice, the last value wins.

Why are all values strings?

A .env file has no types: PORT=5432 is the text 5432. Tick "Convert numbers, true, false and null" if you want those turned into JSON types.

How are values quoted going back to .env?

Plain values like localhost or 5432 are written bare. Values with spaces, #, quotes, = or line breaks are put in double quotes with escapes. null becomes an empty value.

Why can't nested JSON be converted?

Environment variables are flat key and value strings. Flatten the JSON first, for example to DB_HOST and DB_PORT keys.

Is it safe to paste real secrets?

The conversion happens in your browser and nothing is sent anywhere. Still, avoid pasting production secrets on shared computers.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.