ENV to JSON Converter
Convert a .env file into flat or nested JSON, YAML, a typed TypeScript interface, a NodeJS.ProcessEnv declaration, a docker-compose environment block, a Kubernetes ConfigMap, or a shell export script — and back to .env from JSON. The parser handles export prefixes, quoted and multiline values, and inline comments; a validation panel flags duplicate keys, illegal names and detected secrets, with one-click masking for safe sharing.
About this ToolHow it works, benefits & use casesTap to collapse
A .env file is just KEY=value lines, but real-world ones carry export prefixes, single- and double-quoted values with escapes, multiline values, blank lines, and inline # comments. This converter parses all of that robustly and then re-emits your variables in whatever shape the next step needs. From a .env file it can produce flat JSON, nested JSON (splitting keys on __ or .), YAML, a typed TypeScript interface, a NodeJS.ProcessEnv declaration, a docker-compose environment block, a Kubernetes ConfigMap, or a shell export script. It also runs in reverse, flattening a JSON object back into a normalized .env. A coerce-types toggle turns true/false, numbers and null into real typed values, a mask-secrets toggle obscures any value whose key looks like a secret or token so output is safe to share, and a live validation panel flags duplicate keys, illegal variable names, unescaped quotes, and the number of detected secrets. Everything runs in your browser, so the contents of your .env never leave your machine.
How to Use
- 1Pick a direction: ".env to target" to convert a .env file, or "JSON to .env" to go the other way.
- 2Paste your .env content or JSON object into the input panel, or click "Load example" to drop in a sample for the current direction.
- 3In ".env to target" mode, choose an output format: flat JSON, nested JSON, YAML, TypeScript interface, NodeJS.ProcessEnv, docker-compose, Kubernetes ConfigMap, or shell export script.
- 4Toggle "Coerce types" to turn true/false, numbers and null into typed values instead of plain strings.
- 5Toggle "Mask secrets" before sharing to obscure values whose key looks like a secret, token, password, or key.
- 6Read the live output in the sticky panel and check the validation card, then copy, download, or share the result via URL.
Key Benefits
- Robust parser handles export prefixes, quoted and multiline values, escapes, and inline # comments
- Eight output targets from one .env: flat JSON, nested JSON, YAML, TypeScript interface, NodeJS.ProcessEnv, docker-compose, Kubernetes ConfigMap, and shell export script
- Nested mode splits underscore (__) or dot-delimited keys into a structured object
- Reverse direction flattens a nested JSON object back into a normalized .env file
- Optional type coercion converts true/false, numbers and null into real typed values
- Secret masking obscures sensitive values so output is safe to paste into a ticket or chat
- Live validation panel flags duplicate keys, invalid names, unescaped quotes, and counts detected secrets
- Runs entirely in the browser and the output is shareable via URL or pipeable into other tools
Common Use Cases
- Importing a .env file into application config as a flat or nested JSON object
- Generating a typed TypeScript interface or NodeJS.ProcessEnv declaration from your environment variables
- Producing a docker-compose environment block or a Kubernetes ConfigMap from an existing .env
- Creating a shell export script to source the same variables in a terminal session
- Converting a JSON config block back into a .env file for local development
- Auditing a .env for duplicate keys, illegal names, and accidentally committed secrets
10 variables · JSON (flat)
{
"NODE_ENV": "production",
"PORT": 3000,
"DEBUG": false,
"DATABASE__HOST": "localhost",
"DATABASE__PORT": 5432,
"DATABASE__NAME": "my app db",
"API_KEY": "sk_live_5f3c9a1b2d4e6f8a",
"JWT_SECRET": "super-secret-value",
"WELCOME_MSG": "Hello, \"world\"!",
"RETRIES": 5
}
- Value of "WELCOME_MSG" contains an unescaped double-quote.
- 2 values look like secrets — enable masking before sharing.
Conversion
Turn true/false, numbers and null into typed values instead of strings.
Obscure values whose key looks like a secret/token/password/key.
Paste your .env file. Supports export, quotes, multiline values and comments.
More than a JSON dump
A .env file is just KEY=value lines, but real files carry export prefixes, quoted and multiline values, and inline # comments. This converter parses all of that, then re-emits it in whatever shape you need next — flat or nested JSON (keys split on __ or .), YAML, a typed TypeScript interface, a NodeJS.ProcessEnv declaration, a docker-compose environment block, a Kubernetes ConfigMap, or a shell export script.
What the validator checks
- Duplicate keys — where the last value silently wins.
- Names that are not legal env identifiers.
- Values with unescaped quotes that would break parsing.
- A count of values that look like secrets, with one-click masking before you share.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- Environment ManagerParse and validate a .env file, then convert it to JSON, YAML, shell, docker, docker-compose, or Kubernetes - or diff two envs to see added, removed, and changed keys, all in your browser
- Environment Variable GeneratorGenerate .env files from templates
- JSON FormatterFormat and validate JSON with syntax highlighting
- TOML to JSONConvert TOML to JSON format
- JSON to CSVConvert JSON to CSV format
- JSON to TypeScriptGenerate TypeScript interfaces from JSON
Full-line comments (lines starting with #) and blank lines are skipped. For unquoted values, an inline # comment that is preceded by whitespace is stripped. Single-quoted values are treated literally, while double-quoted values support escape sequences such as \n, \t and \" and may span multiple lines until the closing quote. An optional export prefix is recognized and dropped.
A .env file has no types, so by default every value is a string. With coercion on, the value true becomes a boolean true, false becomes false, null becomes null, and bare integers or decimals become numbers. This affects JSON, YAML and the TypeScript outputs. The NodeJS.ProcessEnv and shell outputs always treat values as strings, because that is how they behave at runtime.

