Env to JSON Converter
Convert a .env file of KEY=value lines to a JSON object, or turn a JSON object back into KEY=value lines, with quoted and multi-line values handled correctly.
Direction
Converted live as you type. Nothing leaves your browser.
Options
Keep quotes preserves the original quote characters in each value instead of stripping them.
JSON
{
"API_URL": "https://api.example.com",
"DEBUG": "true",
"SECRET_KEY": "a value with spaces"
}Converted to JSON.
How to convert between .env and JSON
Choose a direction
Pick env to JSON to convert KEY=value lines into an object, or JSON to env to go the other way.
Paste your file
Paste the .env content or the JSON object into the input. The conversion runs the moment there is text.
Adjust the options
Turn on keep quotes, uppercase keys, or switch between pretty printed and minified JSON to match what you need.
Copy or download the result
Copy the converted output or download it as a .json or .env file.
Why use this tool
Two-way conversion
Convert a .env file to a JSON object, or a JSON object back into KEY=value lines, from the same input box.
Handles real .env syntax
Recognises an export prefix, full-line and inline comments, blank lines, and both single and double quoted values.
Multi-line quoted values
A double or single quoted value that spans several lines is read as one value, keeping the line breaks inside it.
Quoting and casing options
Choose whether quotes are kept or stripped, whether keys are forced to uppercase, and whether JSON output is pretty printed or minified.
Runs entirely in your browser
Values often include secrets, so the conversion happens on your device and nothing is uploaded.
About this tool
Environment variable files use a simple KEY=value format, but the details around quoting, comments, and the occasional export prefix vary enough between tools that hand-converting one to JSON, or JSON back to a .env file, is easy to get slightly wrong. This tool does the conversion both ways from a single input box.
Paste .env content and it reads each KEY=value line, skipping blank lines and comments, stripping a leading export keyword, and correctly unwrapping single or double quoted values, including a value that spans several lines inside one pair of quotes. An inline comment after an unquoted value is dropped, matching how most .env loaders behave. Flip the direction and paste a JSON object instead, and each key and value becomes its own KEY=value line, quoting a value automatically when it contains spaces or special characters.
Keep quotes preserves the original quote characters in a value rather than stripping them when reading a .env file, or forces every value to be quoted when writing one. Uppercase keys normalises every key to the shouting-case convention most environment variables use, and pretty print or minified controls the spacing of the JSON output. Everything happens locally, so secrets in a .env file are never sent anywhere. Pair it with the JSON formatter or YAML converter when moving configuration between formats.
Frequently asked questions
- How does the converter handle quoted values?
- A value wrapped in double or single quotes is read as one value with the quotes removed by default, including standard backslash escapes like \n inside double quotes. Turn on keep quotes to preserve the original quote characters in the result instead.
- Can a value span more than one line?
- Yes. If a quote is opened but not closed on the same line, the tool keeps reading following lines until it finds the matching closing quote, and the line breaks in between are kept as part of the value.
- Does it handle a leading export keyword?
- Yes. A line written as export KEY=value, which some shells require to make a variable available to child processes, is read the same as a plain KEY=value line.
- What happens to comments?
- A line that starts with # is skipped entirely. On an unquoted value, anything after a space followed by # on the same line is treated as an inline comment and dropped.
- What does uppercase keys do?
- It forces every key to uppercase in the result, matching the shouting-case convention most environment variables use, regardless of how the keys were originally written.
- Is anything I paste uploaded anywhere?
- No. Environment files often contain secrets, so the conversion runs entirely in your browser and nothing you paste is ever sent to a server.
Related tools
JSON to YAML
Convert JSON to YAML and YAML back to JSON, in both directions, with your choice of indentation.
CUID Generator
Generate collision-resistant CUIDs in bulk, in the standard or a shorter slug form.
cURL to Fetch Converter
Paste a curl command and get the equivalent JavaScript, with the method, headers, body, and basic auth carried across.
Data URI Generator
Turn any file, image, or SVG into a ready-to-paste data URI, with CSS and img snippets.
Dice Roller
Roll d4 to d100 dice with any count and a modifier, and see each die, the subtotal, and the total.
Docker Run to Compose Converter
Paste a docker run command and get the equivalent Compose service definition, with any flag it cannot map listed rather than dropped.