.env to JSON converter

Parse a dotenv file into JSON, or write JSON as KEY=value lines.

Runs in your browser. Your input is not uploaded.

What it does

A .env file holds KEY=value lines that tools such as dotenv, Docker Compose and Vercel load into environment variables. Converting to JSON is handy for secret managers and for checking how values are read.

The parser handles export prefixes, # comments, single quotes (taken literally), double quotes (with \n escapes and multiple lines) and inline comments after unquoted values.

How to use it

  1. Paste the .env contents or JSON.
  2. Choose the direction.
  3. Check the warnings for any lines that could not be read, then copy.

Example

Input
export PORT=3000
NAME="My App" # app name
KEY='raw $value'
Output
{
  "PORT": "3000",
  "NAME": "My App",
  "KEY": "raw $value"
}

Things to watch for

  • Variable expansion such as ${OTHER} is not performed. Different loaders expand differently, so the value is shown as written.
  • All values are strings, as they are in a real environment.
  • Real secrets should not be pasted into tools you have not checked. This one runs locally, which you can confirm in the network panel.

Questions

Does # start a comment inside a value?
Only when it follows a space in an unquoted value. KEY=a#b keeps the #; KEY=a #b drops the comment.
How are multi-line values written?
Inside double quotes, either with real new lines or \n. Converting JSON to .env uses \n escapes.
Which keys are valid?
Letters, digits and underscores, not starting with a digit. Other lines are reported as warnings.
Are my secrets uploaded?
No. Nothing on this page sends what you paste.