.env · transform🔥 popular🔒 100% client-side — never leaves your browser

ENV to JSON Converter

Convert .env to JSON online: paste a dotenv file and this ENV to JSON converter returns a flat JSON object, with optional type coercion that turns 3000 into a number and true into a boolean. Nothing leaves your browser.

By Aliniyaz Mamat · last reviewed

Be the first to rate
{
  "DATABASE_URL": "postgres://user:pass@localhost:5432/db",
  "PORT": 3000,
  "DEBUG": true,
  "OPENAI_API_KEY": "sk-xxxx"
}

Key takeaways

  • ✓Output is one flat object: DB_HOST and DB_PORT stay two keys, they are not nested under DB.
  • ✓Type coercion (on by default) converts integers, decimals, true, false and null. Turn it off to keep every value a string, exactly like process.env.
  • ✓Comments, blank lines and the export prefix are dropped; quoted values keep their inner spaces and #.
  • ✓Escaped quotes inside double quotes ("say \"hi\"") are unescaped correctly.
  • ✓Duplicate keys: the last occurrence wins, the same as dotenv's default behaviour.

What it does

  • ▸Converts a .env file to valid JSON as you type
  • ▸Optional type coercion for numbers, booleans and null
  • ▸Handles double and single quotes, escaped quotes and inline comments
  • ▸Pretty-printed or minified output
  • ▸Copy or download the result, 100% client-side

Privacy

Runs 100% in your browser. Your .env never touches our servers.

client-side only

Usage examples

Case 1 · Coercion on (default)
PORT=3000
DEBUG=false
RATE=0.25
SENTRY_DSN=null
{
  "PORT": 3000,
  "DEBUG": false,
  "RATE": 0.25,
  "SENTRY_DSN": null
}
Case 2 · Coercion off (like process.env)
PORT=3000
DEBUG=false
{
  "PORT": "3000",
  "DEBUG": "false"
}
Case 3 · Quotes, comments, export
# database
export DATABASE_URL="postgres://app@db/app"
SMTP_PASSWORD="abc#123" # keep quotes
GREETING="say \"hi\""
{
  "DATABASE_URL": "postgres://app@db/app",
  "SMTP_PASSWORD": "abc#123",
  "GREETING": "say \"hi\""
}

When to use this tool

  • →Uploading settings to an API that takes JSON (Vercel and Netlify env APIs, AWS Secrets Manager, Azure App Settings bulk edit)
  • →Creating a JSON test fixture or a process.env mock from a real .env
  • →Checking what your app will actually receive before a deploy
  • →Validating config against a JSON Schema or a zod schema

Common mistakes

  • ⚠Leaving coercion on when a value must stay text: 0 and 42 become numbers. Values with leading zeros such as 00123 and numbers like 1e5 stay strings
  • ⚠Expecting nesting: use the JSON to ENV converter for the other direction and nest keys in your app if you need a tree
  • ⚠Shipping the JSON to a browser or a public repo. It holds the same secrets as the .env
  • ⚠Using the JSON for docker-compose: Compose wants a .env file or YAML, not JSON

How .env values map to JSON types

Every value in a .env file is text. Your runtime never sees a number or a boolean: process.env.PORT in Node.js and os.environ["PORT"] in Python are both strings. The converter can show either view, depending on the coerce types switch.

.env linecoerce oncoerce offRule
PORT=30003000"3000"whole numbers within the safe integer range
RATE=0.250.25"0.25"decimals with digits on both sides of the dot
DEBUG=truetrue"true"only the exact lowercase words true / false
DSN=nullnull"null"only the exact word null
EMPTY=""""empty stays an empty string
ID=9007199254740993"9007199254740993"sametoo big for a JS number, kept as text
ZIP=01067"01067"sameleading zeros are kept as text

True, YES or 1 are not turned into booleans, on purpose: libraries disagree about them, and guessing would hide bugs. Validate those in your app, or check the file first with the .env validator.

Parsing rules the converter follows

  • Comments: lines starting with # are skipped. An unquoted value ends at # (space + hash). Inside quotes, # is part of the value.
  • Quotes: double and single quotes are removed. In double quotes, \" becomes ".
  • export: export KEY=value (shell style) is read as KEY=value.
  • Key names: must match [A-Za-z_][A-Za-z0-9_]*. Lines with invalid names are skipped. Run the .env validator to see which ones.
  • Multi-line values: a quoted value spanning several lines (for example a PEM private key) is not supported. Store it on one line with \n escapes.

Doing the same in code

When you need the conversion inside a script or a CI job, every ecosystem has a parser that returns a plain object of strings:

# Node.js (dotenv)
node -e 'const fs=require("fs");console.log(JSON.stringify(require("dotenv").parse(fs.readFileSync(".env")),null,2))'

# Python (python-dotenv)
python -c 'import json;from dotenv import dotenv_values;print(json.dumps(dotenv_values(".env"),indent=2))'

Both return strings only, which equals the converter with coercion off. To go back from JSON to a .env file, use the JSON to ENV converter; to compare two .env files key by key, use the ENV diff checker.

Frequently asked questions

Does the converter create nested JSON from keys like DB_HOST?

No. A .env file is flat, so the JSON is flat too. Splitting on _ would be a guess, because underscores are also part of normal names like NEXT_PUBLIC_SITE_URL.

Are numbers converted to JSON numbers?

Yes, with coerce types on: PORT=3000 becomes 3000 and RATE=0.25 becomes 0.25. Numbers larger than JavaScript's safe integer range stay strings so they are not rounded.

What happens to comments?

They are dropped, because JSON has no comments. Full-line comments and inline comments after an unquoted value are both removed.

What if a key appears twice?

The last value wins, the same as in most dotenv loaders. The .env validator lists duplicate keys so you can clean them up.

Is my .env uploaded anywhere?

No. Parsing happens in JavaScript in this tab; nothing is sent to a server. You can confirm it in the Network tab of your browser's DevTools.

Related tools

Learn more

Compare

coming soon

Get notified when env syncing launches

We're building a tiny tool to keep .env files in sync across teammates and environments. Leave your email — no spam, just a single launch ping.

We use your address only for this launch email. You can ask us to delete it at any time. Privacy policy