.env <-> JSON
Convert KEY=VALUE lines from a .env file into a pretty JSON object, or serialise a JSON object back into .env text. Comments, blank lines, an "export " prefix and surrounding quotes are handled, with optional ${VAR} expansion.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
Two directions, one paste box
The mode option picks the direction. In parse mode the box holds .env text and the tool returns the same keys and values as a pretty JSON object; in build mode the box holds a JSON object and the tool returns ready-to-save .env lines. The input is plain text, so a one-line snippet or a whole multi-line config file works.
How .env text is normalised
Parsing trims each line, skips blanks and # comments, strips a leading export, and removes a matching pair of quotes. Inside double quotes \n, \t, \r, \" and \\ are decoded to real characters, and an unquoted value is cut at a space-and-# comment. The JSON output is indented into a stable shape.
Building .env lines safely
Each JSON value is flattened to a string: null becomes empty, objects and arrays become JSON text, and numbers and booleans stay plain. With the quote option on (the default), a value containing a space, #, quote or backslash is wrapped in double quotes with its contents escaped.
Expansion is opt-in and local
Expansion replaces ${NAME} in unquoted and double-quoted values with the value of an earlier key, leaves single-quoted text literal, and turns unknown references into empty strings, which is why it is off by default. Parsing and building both run in this tab with nothing uploaded, so variables that are often secrets stay on your device.
Questions
Which lines are ignored when parsing?
Blank lines and lines whose first non-space character is # are skipped. An "export " prefix is stripped, and matching single or double quotes around a value are removed.
How does ${VAR} expansion work?
With expansion on, ${NAME} in an unquoted or double-quoted value is replaced by the value of an earlier key. Single-quoted values are left literal.
Does build mode need a JSON object?
Yes. The top level must be a JSON object of key/value pairs, so an array or a bare scalar is rejected with an error. Nested objects become JSON text in the value rather than being flattened, which is what the JSON to .env tool is for.
Related tools
See categoryQuery String <-> JSON
Parse a URL query string into JSON, or build a query string from a JSON object. Local only.
JSON Formatter & Validator
Pretty-print, minify, recursively sort keys or validate JSON, with line/column errors.
JSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.
YAML to JSON
Convert YAML to JSON locally, with indent choice and optional key sorting.