All Tools View Categories About Contact Privacy

.env to JSON Converter

Turn a .env file into a clean, typed JSON object — numbers, booleans, nested keys and all.

Runs entirely in your browser — nothing is uploaded.

About .env to JSON Converter

Configuration lives in a .env file on your laptop, but your CI pipeline, serverless function, Docker secrets manager or test harness wants JSON. Hand-transcribing KEY=value lines into a JSON object is tedious and error-prone — one typo in a quote and your parser silently drops a variable, or worse, a secret ends up a string where a number was expected.

The .env to JSON Converter does the translation for you in one click. Paste your .env, choose your options, and get a valid, prettified JSON object that is ready for JSON.parse. Values become the right JSON types — 8080 stays a number, true stays a boolean, null stays null — instead of every value arriving as a quoted string. Keys separated by __ (or any separator you choose) can be expanded into nested objects, the way many modern config systems expect them.

Everything runs locally: your secrets never leave the page, quoted values are unwrapped correctly, duplicate keys are flagged by line number, and comments and blank lines are handled automatically.

Features

  • One-click conversion: paste .env, get valid prettified JSON.
  • Type-aware values: numbers, booleans and null are detected automatically.
  • Nested keys: expand FOO__BAR into { "FOO": { "BAR": ... } } with a configurable separator.
  • Quote unwrapping: single- and double-quoted values are resolved correctly.
  • Duplicate detection: repeated keys are reported with their line numbers.
  • Comments & blanks: # lines and empty lines are skipped cleanly.
  • Pretty output: two-space indentation, readable and paste-ready.
  • Copy / download: clipboard or a .json file in one click.
  • Private: all conversion happens in your browser.

How to Use

  1. Paste your .env content into the input box, or click Load sample to see a realistic example.
  2. Choose your options. Toggle type detection and nested keys, and set the nested-key separator (default __).
  3. Click Convert. The JSON object appears instantly on the right.
  4. Review the stats — keys converted, comments skipped, any duplicate warnings.
  5. Copy or download the result as a .json file.

Examples

Example 1 — Serverless config. A developer converts a .env with APP_NAME, PORT and DEBUG into JSON for a serverless function’s environment block. With type detection on, PORT becomes 8080 (number) and DEBUG becomes false (boolean), exactly what the runtime expects.

Example 2 — Nested feature flags. A team stores FEATURE__DARK_MODE=true and FEATURE__ANALYTICS=false. With nested keys enabled, the output is { "FEATURE": { "DARK_MODE": true, "ANALYTICS": false } } — perfect for a config-management UI.

Example 3 — Docker secrets. An operator converts DATABASE_URL and API_KEY .env lines to JSON to mount as structured secrets, avoiding shell-quoting issues in the compose stack.

Example 4 — Test fixtures. A QA engineer pastes a production-shaped .env into the tool to generate realistic test fixtures with identical key structure.

Example 5 — Terraform vars. A platform engineer converts env lines to a JSON vars file for infrastructure-as-code, keeping the same variable names across environments.

Benefits

  • No transcription errors: the JSON is derived, not retyped.
  • Correct types: numbers, booleans and null arrive as real JSON types.
  • Structured keys: nested objects match modern config architectures.
  • Safe quotes: DATABASE_URL values with special characters parse cleanly.
  • Duplicate warnings: find conflicting keys before they bite your app.
  • Private & free: no upload, no account, instant results.

Frequently Asked Questions

What does this tool do?
It takes a standard .env file with KEY=value lines and produces an equivalent JSON object. Values like 8080, true, false and null can be auto-detected as real JSON types instead of staying strings, and keys split by a separator (default __) can be expanded into nested objects.
Why would I need .env as JSON?
Many pipelines and tools consume configuration as JSON: serverless config files, Docker secrets or runtime config injected from JSON, test fixtures, Terraform variables, and configuration managers that only accept structured JSON. Converting by hand is slow and prone to quoting mistakes.
How does type detection work?
A value is converted to a number only if it round-trips exactly (String(Number(v)) === v), so 8080 becomes a number but 007 or 5.50 stay strings. true, false and null map to their JSON equivalents; everything else stays a string.
How do nested keys work?
If the Nested keys option is on, a key like FEATURE__DARK_MODE is split on the separator (default __) and expanded to { "FEATURE": { "DARK_MODE": ... } }. Turn it off to keep keys flat as written.
Are quoted values handled?
Yes. A value wrapped in double or single quotes is unwrapped first, so DATABASE_URL="postgres://..." becomes the plain string. Comments and blank lines are ignored (JSON has no comments), and duplicate keys are reported with their line numbers.
Can I use the result with dotenv?
Yes. The JSON is valid for JSON.parse, so you can store it anywhere and load it, or run JSON.stringify on process.env in Node to produce the same shape this tool generates.
Is my data uploaded?
No. Parsing and conversion run entirely in your browser. Nothing is sent to a server, stored or logged.
How do I convert it back?
Use the JSON to .env converter in this same tool family. JSON.stringify the object, paste it there, and get .env lines back — including nested keys re-flattened with the separator.