Boneyard Tools

.env to JSON Converter

Paste a .env file to get clean, two-space-indented JSON, or flip the direction to turn a JSON object back into dotenv lines. Comments and blank lines are dropped, a single pair of surrounding quotes is stripped, and a leading export is handled. Your secrets stay in the browser and are never uploaded.

How to convert .env to JSON

  1. Choose a direction with the toggle: '.env to JSON' or 'JSON to .env'.
  2. Paste your .env text (or a JSON object) into the input box, or click 'Load sample' to try one.
  3. Watch the output box update live as you type; there is no run button.
  4. If a line is malformed, read the inline error and fix that line.
  5. Use 'Copy' to grab the result, or 'Download' to save it as env.json or .env.

Examples

Dotenv to JSON (comments, quotes and export)

# app configuration
PORT=3000
NAME="My App"
export TOKEN=abc123
DATABASE_URL=postgres://user:pass@localhost:5432/db
DEBUG=true
{
  "PORT": "3000",
  "NAME": "My App",
  "TOKEN": "abc123",
  "DATABASE_URL": "postgres://user:pass@localhost:5432/db",
  "DEBUG": "true"
}

Value with an equals sign, plus an empty value

URL=postgres://a=b
EMPTY=
{
  "URL": "postgres://a=b",
  "EMPTY": ""
}

JSON to .env (spaces trigger quoting)

{ "PORT": "3000", "NAME": "My App" }
PORT=3000
NAME="My App"

Frequently asked questions

Are my secrets uploaded anywhere?

No. The conversion runs entirely in your browser, so the values in your .env file never leave your device or get sent to a server. Nothing is logged.

How are comments and blank lines handled?

Lines whose trimmed text starts with # are treated as comments and dropped, and blank lines are ignored. Only KEY=value lines end up in the JSON output.

Does it support the export prefix?

Yes. A leading 'export ' (as in export KEY=value) is recognised and removed, so a line like export TOKEN=abc123 produces the clean key TOKEN with value abc123.

What about values that contain an equals sign?

The line is split on the first equals sign only, so everything after it is kept as the value. That means URL=postgres://a=b parses to the value postgres://a=b rather than being truncated.

How are quotes treated?

A single pair of matching surrounding single or double quotes is stripped from each value. So NAME="My App" becomes My App, while inner quotes and characters are left untouched.

Are numbers and booleans converted to real types?

No. Dotenv values are always strings, so PORT=3000 becomes the string "3000" and DEBUG=true becomes "true". This matches how process.env behaves at runtime.

What happens with a malformed line?

A non-comment line with no equals sign, or one with an empty key, is invalid, so the tool shows an inline error naming the offending line and produces no output until you fix it.

Can I convert JSON back into a .env file?

Yes. Switch the direction to 'JSON to .env' and the tool writes KEY=value lines. Any value containing a space, a #, a quote or edge whitespace is wrapped in double quotes with embedded quotes and backslashes escaped.

How are duplicate keys resolved?

When the same key appears twice, the last value in the file wins, which mirrors how most dotenv loaders behave. The earlier assignment is silently overwritten in the JSON output.

Learn more

Related tools