How to use the Env File to JSON Converter
- 1. Pick the direction.env to JSON, or JSON to .env.
- 2. Paste the contentComments, blank lines and quoted values are fine.
- 3. Copy or downloadGet env.json or a .env file ready to use.
How the sample converts
The sample has a comment, an export line, a quoted value with a space, a double-quoted value with \n and an unquoted value followed by a # comment. The result is 6 variables: NODE_ENV is production (export is removed), APP_NAME keeps its space as Uncodemy Tools, GREETING contains a real line break, API_URL loses the trailing comment and EMPTY is an empty string. Every value stays a string, the same way process.env and os.environ hold them.
Going the other way, JSON values with spaces, quotes or line breaks are wrapped in double quotes and escaped, numbers and booleans become plain text, and nested objects are stored as JSON strings.
Parsing rules
- Blank lines and lines starting with # are skipped.
- Unquoted values are trimmed and lose anything after a space and #.
- Double quotes support \n, \t and escaped quotes; single quotes are taken literally.
- A quoted value can continue across lines until its closing quote.
- If a key appears twice, the last value wins and the key is listed as a duplicate.
Different libraries (dotenv for Node, python-dotenv, Docker's env_file) disagree on a few edge cases such as variable expansion with ${VAR}, which this tool leaves as text. Conversion runs in your browser, but treat real production secrets carefully wherever you paste them. Tick masking to replace values of keys with KEY, SECRET, TOKEN or PASSWORD in their names. Keep the .env out of Git with the .gitignore generator and tidy the JSON with the JSON formatter.
Frequently asked questions
Why are numbers shown as strings in the JSON?
Environment variables are always text. Your app converts them, for example Number(process.env.PORT).
Does it expand ${OTHER_VAR}?
No. Expansion depends on the library, so the value is kept exactly as written.
Is the Env File to JSON Converter free?
Yes, the Env File to JSON Converter is free. The first time you convert your first file, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.