.env ⇔ JSON Converter
Paste the contents of a .env file to convert it to JSON, or paste JSON to get .env lines — handy when moving environment variables into CI/CD settings or a cloud dashboard. If you need YAML, try the YAML ⇔ JSON Converter.
🔒 Runs in your browser · Your data is never sent to a server
Notes
- Lines starting with # and anything after " #" in an unquoted value are treated as comments and are not included in the JSON.
- Double-quoted values interpret escapes such as \n, \t and \", while single-quoted values are taken literally. Quoted values may span several lines.
- If a key appears more than once, the last value wins.
- JSON→.env only supports a flat object whose values are strings, numbers, booleans, or null. Nested objects and arrays are reported as errors.
- By default all values stay strings (to keep values like 0123). Check the box to convert numbers and true/false to JSON types.
Glossary
.env
A text file that lists environment variables as KEY=VALUE lines. It keeps settings such as API keys and database URLs separate from your code.
Environment variable
A setting passed to a process by the operating system. It lets an app behave differently per environment without changing its code.
JSON
Short for JavaScript Object Notation, a text format for representing data as key-value pairs.
FAQ
How are comments in a .env file handled?
Lines starting with # and anything after " #" in an unquoted value are ignored and not included in the JSON. To keep a # inside a value, wrap the value in double or single quotes.
What is the difference between double and single quotes?
Double-quoted values interpret escapes such as \n and \". Single-quoted values are taken literally. Both can span several lines up to the closing quote.
Can I convert nested JSON to .env?
No. A .env file is flat KEY=VALUE lines, so JSON containing objects or arrays is reported as an error. Flatten the keys first, then convert.
Why is PORT=3000 a string "3000" in the JSON?
By default every value stays a string. Check "Convert numbers and true/false to JSON types" to get 3000 as a number. Values with leading zeros such as 0123 and integers too large to represent safely stay strings.
Share this page
