{ }jsonkit
Format
Validate
Convert
Query
Generate

.env to JSON converter

Convert .env to JSON or YAML and back, or validate a .env file.
Mode
95 B · paste or drop a file
1 2 3 4 5
✓ complete95 B → 131 B0.0 ms

About .env ⇄ JSON / YAML

This .env to JSON converter turns environment variables into nested JSON and back. A variable such as DATABASE__HOST becomes database.host, and the same double underscore convention works in reverse, so the conversion round-trips.

The same page converts .env to YAML and YAML to .env, for config that lives in YAML files and environment variables at the same time. Validate mode checks a .env file for invalid names, broken quotes, duplicates, empty values and undefined ${VAR} references, without ever printing a value.

Runs in your browser. Nothing is uploaded, so real secrets stay on your machine.

How it works

Environment to JSON or YAML

A variable such as DATABASE__HOST becomes a nested property. Values stay strings by default. Optional type inference recognizes strict booleans, null, JSON-style numbers, arrays and objects.

JSON or YAML to environment

Objects are flattened recursively and nested keys are joined with __. Names are normalized and checked for collisions, so no variable overwrites another. Arrays become JSON text in a single quoted value.

Safe quoting

Values with whitespace, comment characters, newlines or JSON array text are double-quoted and escaped, and so are empty strings. Simple values stay unquoted.

Strict parsing

The parser supports comments, export prefixes, unquoted values, single and double quotes, escapes and multiline quoted values. Invalid names, broken quotes, duplicate definitions and a path used as both a value and an object all cause errors. No data is dropped without a message.

Validate a .env file

Validate mode reports every problem by line: invalid names, missing equals signs, broken quotes, repeated variables and empty assignments. With reference warnings on, it also finds ${NAME} references that have no definition in the same file. The report lists names and line numbers only.

Frequently asked questions

Why are values strings by default?

Environment variables are always strings. Type inference is opt-in because values like 00123 are often IDs, not numbers.

Why use __ instead of a single underscore?

Many names already contain single underscores. A double underscore marks nesting without clashing with them.

Can a top-level JSON array become .env?

No. A .env file is a set of named variables, so the JSON root must be an object.

How are arrays stored?

As JSON text, quoted inside one environment variable. With type inference on, they turn back into arrays.

Are ${VAR} expressions expanded?

No. They stay as text. In Validate mode they are only checked for a missing definition in the same file.

Can the validation report leak a secret?

No. It contains variable names and line numbers only. Parsed values are never copied into it.

Sources & last verified

We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.

Found a wrong result or an outdated claim? Report an error and we will check it again.