.env to JSON Converter

Convert .env files to JSON using dotenv rules: export prefix, comments, single and double quotes, escapes and multiline values. Free, processed locally.

Runs entirely in your browser. Your data is never uploaded.

Related Tools

View All

What is ENV to JSON?

Turn a .env file into a JSON object of variable names and values. The parser understands the syntax used by dotenv and most frameworks: comments, an optional export prefix, quoted values, escape sequences and values that span several lines.

How to use ENV to JSON

  1. Paste .env into the .env input box, or use Load sample or Open file.
  2. Choose the JSON Indentation.
  3. The JSON output updates as you type; use Copy or Download.

Example

Input
export DB_HOST=localhost
PASS="p@ss \"x\"" # c
Output
{
  "DB_HOST": "localhost",
  "PASS": "p@ss \"x\""
}

When to use ENV to JSON

Use it to inspect environment files, convert them for tools that take JSON, or check how a tricky quoted value is parsed. Avoid pasting production secrets into any online tool on shared machines – this one runs locally, but the text stays in your browser tab.

How ENV to JSON works

Each entry is KEY=value (or KEY: value), optionally prefixed with export. Unquoted values are trimmed and cut at a # comment. Single-quoted and backtick-quoted values are literal; double-quoted values decode \n, \r, \t, \" and \\. Quoted values may span multiple lines, and an unclosed quote is reported with its line number. Variable references like ${HOME} are not expanded, and every value stays a string.

Common Use Cases

  • Convert .env settings into JSON for a cloud console or secrets manager
  • Debug how a multiline private key in .env is parsed
  • Compare two environment files as JSON
  • Generate JSON config for a test runner from .env

Security Note

Values are parsed in your browser and never uploaded, but .env files often contain secrets: clear the input when you are done on shared computers.

FAQs

Is ${VAR} expansion supported?

No, values are returned exactly as written. Expansion depends on the tool (dotenv-expand, Docker Compose) and is left to it.

Why is everything a string?

Environment variables are always strings; converting them to numbers or booleans is up to your application.

Where do inline comments start?

In unquoted values, at a # that follows whitespace. A # inside quotes or without a preceding space (like a URL fragment) is part of the value.

Good next steps

Explore more categories