ENV to JSON Converter
Convert .env files to JSON online. Paste environment variables and get clean, nested JSON instantly — reconstructs objects and arrays from double-underscore key naming, all in your browser.
Features
🔧 Real .env Support
- Quoted values (single and double) with escapes
export KEY=valueprefix stripped automatically- Comments and blank lines skipped
- Configurable nesting separator
🔄 Structure Reconstruction
- Nested objects from
DATABASE__HOSTstyle keys - Arrays rebuilt from consecutive numeric segments
- Optional type inference for numbers/booleans
- Pairs with our JSON to Env converter
⚡ Privacy-First
- All parsing happens in your browser
- No data ever sent to a server
- Never paste real production secrets into any web tool
- Download or copy the resulting JSON instantly
ENV to JSON Guide
A .env file is just a flat list of KEY=value pairs — Node's dotenv, Docker Compose, and countless deployment tools all read this format directly. But flat key/value pairs don't map cleanly onto structured application config, which is usually a nested JSON object. This tool reverses the convention used by our own JSON to Env converter: nested JSON keys are flattened into environment variable names using a separator (double underscore by default, since single underscores commonly appear inside real variable names), and this tool splits those names back apart to rebuild the original object shape.
Numeric segments in a key path (e.g. ITEMS__0__NAME, ITEMS__1__NAME) are automatically detected and reassembled into a JSON array rather than an object with string-numeric keys, so round-tripping a config that contains lists works as expected.
Frequently Asked Questions
Why is double underscore the default separator?
A single underscore is extremely common inside real environment variable names (DATABASE_URL, API_KEY), so using it as a nesting delimiter would incorrectly split ordinary keys. Double underscore is a widely used convention (popularized by Docker and Kubernetes ConfigMaps) specifically because it rarely appears by accident.
What happens to keys that don't use the separator?
They become plain top-level JSON keys with no nesting — the converter only builds nested structure where the separator actually appears in a key name, so flat .env files convert to flat JSON objects.
Are quoted values handled the same as dotenv libraries?
Yes for the common cases: double-quoted values support \n, \t, and escaped quotes; single-quoted values are taken literally with no escape processing, matching how most dotenv parsers (including the popular Node dotenv package) behave.
Can I convert the JSON back into a .env file?
Yes — paste the resulting JSON into our JSON to Env converter with the same separator selected, and it will flatten the object back into KEY=value lines. Round-tripping works cleanly as long as your keys don't contain the separator sequence for a reason other than nesting.