.env to JSON

Convert between .env files and JSON in both directions.

Runs on your deviceFreeNo sign-up
Runs in your browser
Loading tool…

Designed to run in your browser. See the privacy policy.

About .env to JSON

This tool converts between dotenv files and JSON in both directions. In ".env → JSON" mode it reads KEY=value lines and produces a JSON object, which is handy for pasting environment settings into a cloud console, a secrets manager import, a test fixture or a config file. In "JSON → .env" mode it turns a flat JSON object back into a .env file you can drop into a project.

.env files often hold API keys, database passwords and tokens. The conversion is designed to run in your browser, so the text is processed on your device rather than on a conversion server. Even so, treat any page you paste secrets into with care, and consider replacing real secrets with placeholders when you only need the structure.

How to use

  1. Choose the direction at the top: ".env → JSON" or "JSON → .env".
  2. Paste the contents of your .env file, or a JSON object, into the input box.
  3. Check the output panel; if something cannot be converted, an error message explains why.
  4. Copy the result, or download it as output.json or as a file named .env.

FAQ

Which .env syntax is supported?+
Each KEY=value line becomes one entry. Blank lines and lines starting with # are skipped, as are lines without an equals sign. A value wrapped in matching single or double quotes has those quotes removed. If a key appears twice, the last value wins.
Are there .env features it does not handle?+
Yes. It does not expand ${VAR} references, process escape sequences such as \n, read multi-line values, or strip a trailing # comment after a value. A leading export keyword is kept as part of the key name. All values come out as JSON strings, including numbers and true or false.
What JSON can I convert to a .env file?+
A flat object whose values are strings, numbers or booleans. Nested objects, arrays and null are rejected with an error naming the key, because .env files have no way to represent them.
How are values quoted in the .env output?+
Values containing spaces, #, quotes or backslashes are wrapped in double quotes, and double quotes inside them are escaped with a backslash. Other values are written without quotes, for example PORT=3000.