Env to JSON converter

Paste configuration text to convert between .env and a JSON object of strings. Select how repeated .env names should be handled; conversion stays local.

Convert text locally. JavaScript is required; no input is uploaded or stored.

How it works

Node.js documents its own .env rules because there is no universal specification. This converter follows a documented subset: names contain ASCII letters, digits and underscores and cannot start with a digit. An optional export prefix is ignored. Unquoted values lose surrounding whitespace and end at #; single- or double-quoted values retain whitespace, hashes and literal newlines.

Values remain strings: 3000 and false are not converted to a number or boolean. No variable interpolation or shell execution occurs. Quoted text ends at the next matching quote; escaped quotes are unsupported. Double-quoted backslash-n and backslash-r sequences are rejected because escape handling differs across dialects; use literal newlines or single quotes.

Duplicate .env assignments are reported with a selectable first, last or reject policy. JSON must be an object containing only strings; use unique JSON keys because JSON parsing retains the last repeated key. JSON output loses comments and formatting. For .env output we select a quote absent from the value; values containing both quote types, NUL or carriage returns are rejected. Input and generated .env text are limited to 512 KiB and 10,000 lines. No numeric rounding occurs.

Worked examples

Strings stay strings

PORT=3000 and DEBUG=false become {"PORT":"3000","DEBUG":"false"}.

Duplicates are visible

A=1 followed by A=2 produces {"A":"2"} under last-value policy, with one duplicate reported. First-value policy gives {"A":"1"}.

Frequently asked questions

Does this support every dotenv library?
No. It implements the documented Node.js-style subset above and rejects ambiguous escapes.
Will true become a JSON boolean?
No. Environment values are strings. JSON-to-env rejects booleans, numbers, null, arrays and nested objects.
Are variables such as ${HOME} expanded?
No. Dollar signs and references are preserved as literal text.
Can quoted values span lines?
Yes. Actual line breaks inside matching single or double quotes are preserved.
Can I share a link containing this input?
This converter does not put configuration into URLs or browser storage. Copy output explicitly if needed.

Sources

Last reviewed 2026-11-14. The method is written out above so you can check our math.