100% local — your data never leaves your browser

.env to JSON — Settings Your Code Can Read

Turn a .env file into JSON. Quotes, comments and export are handled, so the settings arrive as an object your app or CI can read directly.

Instant Private Zero cookies
Indentation

.env input

JSON output

What this tool does

A .env file becomes a flat JSON object.

# service
export PORT=8080
NAME="Ada Lovelace"
EMPTY=
{
  "PORT": "8080",
  "NAME": "Ada Lovelace",
  "EMPTY": ""
}

Comment lines and blank lines are skipped, a leading export is removed, and the quotes around a value are removed with it. Inside double quotes, \n and \t become a newline and a tab; inside single quotes, everything stays literal, as in a shell.

A variable set twice is refused

PORT=8080
PORT=3000
Duplicate variable "PORT" on line 2: it already has a different value

A shell keeps the last assignment and says nothing, so the first value simply vanished. In a .env that has been merged, edited and copied between environments, that silence is expensive: you read the file, you see PORT=8080 at the top, and the process runs on 3000. The converter now stops and names the variable and the line. Two identical assignments are not the admission of anything, so they still pass. That was a real defect, found while writing this page and fixed.

Everything is a string

ID=007
ACTIVE=true
COUNT=3
{
  "ID": "007",
  "ACTIVE": "true",
  "COUNT": "3"
}

An environment variable is text: that is what the operating system stores and what process.env gives back. Typing COUNT as a number here would be a guess, and typing ID as one would lose its zeros. The conversion keeps the text, and the typing stays where the meaning is known — in your code.

What the format does not carry

  • Expansion. PATH=$HOME/bin stays $HOME/bin. What $HOME holds depends on a machine this page cannot see.
  • Nesting. .env is a flat list of names and values; there are no sections and no structure to find.
  • A comment after a quoted value. A="a #b" keeps its hash, because it is inside the quotes. After a bare value, # starts a comment and is cut.
  • Any name you like. A name must be letters, digits, _ and ., and not start with a digit — the rule a shell itself applies. Anything else is refused by name rather than written into JSON that no .env could hold again.

Private by design

Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.

Frequently asked questions

Why is a variable set twice refused?
Because one of the two values was disappearing without a word. A shell keeps the last assignment, so the tool did too — and a `.env` with `PORT` on line 3 and again on line 40 usually means a merge went wrong, not a decision. The conversion now stops and names the variable and the line. Repeating the same value changes nothing, so that passes.
Why is `PORT=8080` a string in the JSON?
Because an environment variable is text — that is all the operating system holds. `8080`, `true` and `007` are strings on the way in and strings on the way out; `process.env.PORT` is a string too. A converter that typed them would decide for you, and would turn a padded identifier into a number on the way.
Is `$HOME` expanded?
No. `PATH=$HOME/bin` gives you the string `$HOME/bin`, exactly as written. Expansion is the shell’s job, it depends on an environment this page cannot see, and guessing at it would put a value in your JSON that never existed in your file.

Related converters