Env to JSON Converter
This tool converts the contents of a .env (dotenv) file into a JSON object
This tool converts the contents of a .env (dotenv) file into a JSON object
How to use Env to JSON Converter
- Paste the contents of your .env file into the input box.
- Optionally enable type casting to convert booleans, numbers and null to real JSON types.
- Copy the JSON output or download it as an env.json file.
About Env to JSON Converter
This tool converts the contents of a .env (dotenv) file into a JSON object. Paste your KEY=VALUE lines and it returns clean, indented JSON you can copy or download. It follows the common dotenv conventions: it skips blank lines and # comments, strips an optional leading "export ", and understands single-quoted values (kept literally) and double-quoted values (where , \r, , \\ and \" escapes are expanded). Unquoted values are trimmed, and a space-preceded # is treated as an inline comment.
By default every value stays a string, which is the safest representation of a .env file. Turn on the type-casting option to convert true and false to booleans, whole and decimal numbers to numbers, and null to a JSON null — useful when you want a config object rather than raw strings. If the same key appears twice, the last value wins (matching how a process actually loads environment variables) and the tool notes which keys were duplicated.
Everything runs entirely in your browser. Your file is never uploaded or sent anywhere, which matters because .env files often hold secrets like API keys and database passwords. The conversion is a best-effort parser for standard dotenv syntax; it does not resolve variable references such as ${OTHER_VAR}, and unusual or malformed lines are reported and skipped rather than guessed.
Frequently asked questions
- How do I convert a .env file to JSON?
- Open your .env file, copy its contents, and paste them into the input box. The JSON output appears instantly below, and you can copy it or download it as env.json. There is no upload step.
- Are my environment variables and secrets safe?
- Yes. The entire conversion happens locally in your browser using JavaScript. Nothing is uploaded, logged, or sent to any server, so API keys and passwords in your .env stay on your machine.
- Does it keep values as strings or convert types?
- By default every value is kept as a string, which mirrors how a .env file is stored. Enable the type-casting option to turn true/false into booleans, numeric text into numbers, and null into a JSON null.
- What .env syntax does it support?
- It handles KEY=VALUE lines, # comments, blank lines, an optional leading 'export ', inline comments after unquoted values, and both single- and double-quoted values. Double-quoted values expand escape sequences like and .
- Does it resolve variables like ${DATABASE_URL}?
- No. The tool treats values literally and does not perform variable interpolation or reference expansion. A value of ${OTHER} is output as the literal text, not the resolved value.
- What happens if a key is duplicated?
- The last occurrence of a key wins, matching how most processes load environment variables. The tool also lists any duplicated keys so you can spot accidental repeats.