Tools

.env to JSON converter

Convert a .env file to JSON, docker -e flags or a Compose environment block, and JSON back to .env, parsed exactly as dotenv does.

Runs in your browserData formats20.5K
Free

Input

0 B

Result

The result will appear here.

A .env file looks too simple to get wrong until a value contains a #, a quote or a line break. This tool reads it with a line-for-line port of the parser in motdotla/dotenv, the package most Node projects load their environment with, so what you see here is what process.env would contain. Convert it to JSON for a secrets manager or a test fixture, to -e flags for docker run, or to the environment: block of a Compose file — or go the other way and turn a JSON object into a .env file whose quoting survives being read back.

How it works

  • An unquoted # starts a comment even in the middle of a value, which is dotenv's rule and a common source of truncated URLs.
  • Single-quoted and backtick values are literal; only double quotes turn \n into a real line break.
  • export KEY=value and KEY: value are both accepted, and a key defined twice keeps its last value — the stats list which keys repeat.
  • Non-blank lines that are neither comments nor variables are listed by line number, so a typo does not vanish silently.
  • Docker flags are shell-quoted, and the Compose output quotes any value YAML would otherwise read as something else, so true, null or 5432 stay strings instead of becoming a boolean, a null or a number.

Where your data goes

Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.

This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.

What it costs

This tool is free, with no sign-in and no points.

Common questions

Why was my URL cut off at the #?
dotenv treats # as the start of a comment wherever it appears in an unquoted value, so URL=https://example.com/#section ends at the slash. Put the value in quotes — URL="https://example.com/#section" — and the # is kept.
How do I store a multi-line value, like a private key?
Either use double quotes with \n escapes on one line, or double quotes spanning several real lines; dotenv reads both. The JSON to .env direction writes the one-line escaped form, which is the one that survives being pasted into CI secret settings; only a value that contains both a line break and a double quote is written in backticks across several lines, because dotenv has no other way to read it back.
Does it expand ${VARIABLE} references?
No, and neither does dotenv on its own. Expansion is the job of the separate dotenv-expand package, and Docker Compose applies its own interpolation rules. The values shown here are exactly what dotenv's parse returns, references included as literal text.
Is it wise to paste production secrets here?
Nothing leaves the page — no request is made while converting — but a .env full of production credentials is worth handling as little as possible anywhere. Swapping the values for placeholders first is a sound habit; the structure converts the same way.

The open-source behind it

This tool is a self-contained implementation. motdotla/dotenv (BSD-2-Clause) does the same job as a library — if you need this behaviour inside your own program, start there rather than calling a web page.

motdotla/dotenv

Also known as

  • .env to json
  • env to json
  • json to env
  • dotenv parser online
  • env file to docker env
  • env to docker compose