.env to JSON

Paste the contents of a .env file and get a JSON object, with quotes, escapes, comments, export prefixes, multi-line values and ${VAR} references handled.

Use the tool

Why this tool exists

Environment files are everywhere, but sometimes you need the same settings as JSON: for a config loader, a CI secret store that takes JSON, a Kubernetes manifest or a quick comparison between two environments. Splitting on the first equals sign does not cut it, because of quoted values, inline comments and variable references.

This parser follows common dotenv rules: double-quoted values process escapes and can span lines, single-quoted values are literal, unquoted values lose trailing comments, and ${VAR} and ${VAR:-default} can be expanded. You can convert numbers and booleans, or nest keys on a separator. Real secrets in .env files should not be pasted into pages you do not trust; this one works locally.

How to use it

  1. Paste the .env contents.
  2. Choose whether to convert numbers and booleans, expand variable references and nest keys.
  3. Copy the JSON object.

Frequently asked questions

How are quotes handled?

Double-quoted values support \n, \t and escaped quotes and may span several lines. Single-quoted values are taken literally and are never expanded. Unquoted values end at a space followed by a hash.

What does nesting do?

With a separator of double underscore or single underscore, DB__HOST=x becomes {"db":{"host":"x"}}. Keys are lowercased when nested. With none, the keys remain flat and keep their case.

Are real secrets safe here?

Parsing runs in your browser and nothing is uploaded. Still, avoid pasting live production credentials into any web page. Use sample values when you only need the format.

What if a line is invalid?

The tool stops and names the line number that does not look like KEY=value, or an unclosed quote, so you can fix that line.