Skip to content
{ }JSON Formatter

.env to JSON

Parse a .env file into a JSON object — comments and blank lines skipped, quotes and export prefixes handled. For inspecting or diffing config.

Input
Output
Paste input and press To JSON.

Dotenv in, JSON out

Paste the contents of a .env file and get a JSON object of its key/value pairs — useful for inspecting configuration, diffing two environments, or feeding env data into a tool that speaks JSON. The parser follows the usual .env rules: it skips blank lines and # comments, tolerates an export prefix, unwraps single- or double-quoted values (decoding \n and escaped quotes), and strips trailing inline comments from unquoted values.

Flat by design

The result is a flat object keyed by the exact variable names — including any __ in them. Reconstructing nested structure from underscores is ambiguous (is DB_HOST nested or just a name?), so the tool keeps the keys verbatim rather than guessing. Values are strings, because that is what environment variables are.

Comparing environments

Convert two .env files to JSON and drop them into the JSON Diff tool to see exactly which variables differ — a fast way to catch a missing key or a wrong value between staging and production. The reverse direction is JSON to .env.

Frequently asked questions

Does it handle comments and the export prefix?

Yes — lines starting with # and blank lines are skipped, and an export KEY=value prefix is stripped. Trailing inline comments after an unquoted value ( # …) are removed too.

Are quoted values handled?

Yes. Double-quoted values are unwrapped and decode \n and escaped quotes; single-quoted values are taken literally (no escape processing), matching dotenv behaviour.

Why is the output flat rather than nested?

Because underscores in env names are ambiguous — DB_HOST could be a nested path or just a name. Guessing would corrupt some configs, so the tool preserves the exact keys. Split them yourself if you know the intended structure.

Are values typed?

No — every value is a string, faithfully reflecting how the shell sees it. PORT becomes "8080", not 8080. Convert types in your own code where you know the schema.