.env to JSON converter

Convert env files to JSON and back for config tools.

FreeRuns in your browserNo signupUpdated 2026-10-29

Comments and blank lines are skipped. Quoted values keep their type as strings. Switching direction feeds the output back in. Nothing is uploaded.

Top-level keys

7

Status

Valid

Parsed without errors

config.json
{
  "DATABASE_URL": "postgres://app:secret@db.internal:5432/app?sslmode=require",
  "DB_POOL_SIZE": 10,
  "NODE_ENV": "production",
  "APP_NAME": "Order Portal",
  "DEBUG": false,
  "WELCOME_MESSAGE": "Hello,\nworld",
  "EMPTY": ""
}

About this tool

How it works and how to read the result.

Need this done for you?

Web app & SaaS development

SaaS products and web apps, from first version to scale.

See the service

What it does

An env to JSON converter reads a .env file and produces a JSON object with the same keys and values, which is the shape most deployment platforms, secret managers and config loaders accept when importing variables in bulk. It also works in reverse, flattening a JSON object into KEY=value lines with correct quoting. Comments, blank lines, the export prefix, single and double quotes and escaped newlines are all handled the way dotenv libraries handle them, so the result matches what your application would actually read.

How to use it

  1. Choose the direction: .env to JSON, or JSON to .env.
  2. Paste the file. Comments and blank lines are skipped automatically.
  3. Decide whether unquoted numbers and booleans should become JSON types, and whether double underscores should create nested objects.
  4. Copy the output or download it. Switching direction feeds the output back in as the new input, which is a quick way to round-trip a file.

How to read the result

The sample .env has seven variables, two comments and a blank line. The converter reports seven top-level keys and a green "Valid" badge. DATABASE_URL keeps its full connection string as a string because it was quoted. DB_POOL_SIZE becomes the number 10 and DEBUG becomes the boolean false, since both were unquoted and type conversion is on. The export prefix on NODE_ENV is dropped, because it is shell syntax rather than part of the name. WELCOME_MESSAGE shows a real line break inside the JSON string, as the escaped n in double quotes is expanded, and the trailing comment after it is ignored. EMPTY becomes an empty string rather than null.

If the badge turns red, the hint names the first problem line, usually a line without an equals sign. In the JSON to .env direction, values containing spaces, hashes or quotes are wrapped in double quotes so the file reads back correctly, and nested objects are flattened with double underscores.

Configuration handling is part of every web app deployment we set up. For YAML-based configs, the YAML to JSON converter does the equivalent job.

Questions

Frequently asked.

Is it safe to paste real secrets?

The conversion runs in your browser and nothing is transmitted, so the values never leave your machine. Even so, treat the page like any other window with secrets in it: do not screenshot it, and close the tab when you are done. Rotate any key you suspect has been exposed elsewhere.

Why is a number in quotes still a string?

Quoting a value in a .env file is the usual way to say "keep this as text", for example a zip code with a leading zero or a version such as "1.10". The converter respects that. Unquoted numbers and the words true, false and null are converted to JSON types when the option is on.

What does nesting on double underscore do?

Many config libraries, including ASP.NET and several Node packages, map DATABASE__HOST to a nested object with database and host keys. Turning the option on produces that structure. Leave it off for platforms such as Vercel, Docker Compose or GitHub Actions, which expect a flat list of variables.

Your next move

Like what you see? Tell us about it.

A process that takes too long, a website that undersells you, or an idea ready to take shape. Tell us where you are and we will suggest a useful next step.

India · Working with clients worldwide

We reply within a working day. No spam, ever.