Skip to content

Menu

.env to JSON

Convert .env files to JSON

Runs entirely in your browserConvertersFree, no sign-up
Loading tool

01What is .env to JSON?

Some tools want a JSON config file, and your settings live in a .env file. Paste the .env here and the converter returns JSON with typed values and camelCase keys. Lines are read with the same rules as the Node dotenv package, and we checked our parser against its behaviour. Blank lines and # comments are skipped, and an optional export prefix is allowed. Whitespace around unquoted values is trimmed. In an unquoted value, a # starts a comment. Values wrapped in single quotes, double quotes or backticks keep their inner text exactly, including # characters and line breaks. That means multi-line values such as private keys survive. Inside double quotes, \n and \r turn into real line breaks. Unquoted values are then typed. You get booleans for true, True and TRUE plus the matching false spellings. Integers become numbers only inside JavaScript's safe-integer range, and decimals become numbers too. Everything else is a string. Numbers with leading zeros such as 00123 stay strings, and any quoted value always stays a string. Empty values become empty strings. Keys are lowercased and converted from UPPER_SNAKE to camelCase, so APP_SECRET_KEY becomes appSecretKey. With "Unflatten to nested objects" ticked, keys that share a first segment are grouped. If DATABASE_HOST, DATABASE_PORT and DATABASE_NAME all exist, you get a database object with host, port and name. A prefix used by only one key stays flat. A short example shows the comment rule in action. PASSWORD=abc#123 comes out as "password": "abc", because the unquoted # starts a comment. KEY=`a#b` comes out as "key": "a#b", because backtick quotes protect it. That first case catches people out, and it matches what dotenv itself does. There are limits you should plan around. Nesting is only one level deep and splits on the first underscore, so DB_READ_HOST becomes db.readHost rather than db.read.host. Variable expansion like ${HOME} is not performed. The text is copied as written. Lines that aren't KEY=value assignments are dropped without a warning, so a typo can quietly lose a setting. Compare the key count before you trust the result. The parsing runs in your browser tab, so the secrets in your .env are not sent to our server. Still, treat the JSON you copy with the same care as the original file.

Node.js and full-stack developers, DevOps engineers and anyone moving configuration between .env files and JSON-based tooling. The tool runs entirely in your browser, so your data never leaves your device.

02How to use .env to JSON

  1. Paste the contents of your .env file into the .env Input panel.
  2. Leave Unflatten to nested objects ticked for grouped keys, or untick it for a flat camelCase object.
  3. Check the JSON Output, particularly any values that were typed as numbers or booleans.
  4. Click Copy JSON.

03Worked examples

Input: PORT=08080 RETRIES=3 RATIO=0.75 DEBUG=True
Result: { "port": "08080", "retries": 3, "ratio": 0.75, "debug": true }
A number with a leading zero stays a string, so values like zip codes or 08080 are not changed.
Input: PORT="3000" NAME='my app' MSG="line1\nline2"
Result: { "port": "3000", "name": "my app", "msg": "line1\nline2" }
Quoted values always stay strings. \n becomes a real newline only inside double quotes.
Input: export API_URL=https://x.io # prod EMPTY=
Result: { "apiUrl": "https://x.io", "empty": "" }
The export prefix and the trailing # comment are removed, the same way the dotenv package handles them.
Input: DB_HOST=localhost DB_PORT=5432 APP_NAME=demo (Unflatten to nested objects on)
Result: { "db": { "host": "localhost", "port": 5432 }, "appName": "demo" }
A prefix becomes a nested object only when two or more keys share it. APP_NAME is the only APP_ key, so it stays flat.
Input: BIG=9007199254740993
Result: { "big": "9007199254740993" }
Integers outside JavaScript's safe-integer range stay strings, because a number would silently lose precision.
Input: PASSWORD=abc#123 KEY=`a#b`
Result: { "password": "abc", "key": "a#b" }
An unquoted # starts a comment, as in dotenv. Backtick quotes keep the # as part of the value.

04Common use cases

  • Turning a Node project's .env into a config.json for a tool that doesn't read env files
  • Building a typed config object shape before writing a Zod or Joi schema for it
  • Comparing two environments by converting each .env to JSON and diffing them
  • Moving local settings into a JSON-based secrets store or parameter file
  • Documenting the configuration keys of a service in a README
  • Generating a JSON fixture of config values for unit tests that mock process.env

05Tips

  • Quote values that look numeric but must stay strings, like a port you pass straight to a URL or a numeric account ID; quoted values are never converted.
  • An unquoted value stops at the first #, so PASSWORD=abc#123 is read as abc, exactly as dotenv does. Wrap such values in quotes.
  • Don't paste production secrets into shared screens or commit the resulting JSON; treat it as sensitively as the .env.
  • If you need deeper nesting, use a double underscore convention in your app and post-process the output.
  • If the same key appears twice, the later line wins and the earlier value is silently dropped. Search your .env for duplicates before converting.

06Related concepts

dotenv, Environment variables, camelCase, Twelve-factor config, JSON.

Frequently Asked Questions

What is .env to JSON?

.env to JSON is a free, browser-based developer tool on AIDToolStack. Convert .env files to JSON It requires no installation or sign-up and works entirely in your browser.

Is .env to JSON free to use?

Yes. No sign-up, no fees and no usage cap.

Does .env to JSON store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe