.env to JSON / YAML Converter
Your data never leaves your browserPaste a .env file, get JSON or YAML. Handles comments, quotes, export prefixes, and nested keys. Runs entirely in your browser.
Share this tool
Found it useful? Help a fellow developer discover it.
Convert in the other direction
Going the other way, flattening a JSON or YAML config into a .env file?
Convert JSON or YAML to .env
Reading a .env file as JSON or YAML
Local development runs on .env files loaded by dotenv, but almost everything downstream wants structured config. Kubernetes expects secrets and ConfigMaps as YAML manifests. Cloud secret managers and deployment APIs take JSON. CI pipelines like GitHub Actions read YAML key-value blocks. Retyping a .env file into those formats by hand is tedious and error-prone, and it is where a stray quote or a missing variable slips in. Paste the .env file here and get clean JSON or YAML you can drop straight into a manifest or an API call. The parser handles the real-world edge cases that trip up naive converters. It recognizes lines starting with the export keyword. It strips values wrapped in single or double quotes. It expands double-quoted values with escape sequences like \n and \t. It handles empty values. It also strips inline comments after values. Keys that use a double underscore, like DB__HOST, are expanded into nested objects.
Frequently Asked Questions
How do keys like DB__HOST become nested objects?
A double underscore marks a level of nesting. DB__HOST=localhost and DB__PORT=5432 become {"DB": {"HOST": "localhost", "PORT": "5432"}} in the JSON or YAML output. This matches the convention ASP.NET Core and many other frameworks use for hierarchical config in environment variables. If the same name is used both as a value and as a prefix, such as DB=x alongside DB__HOST=y, the converter reports the conflict instead of guessing.
Why are numbers and booleans output as strings?
Environment variables are always strings. The operating system passes PORT=5432 to your process as the text "5432", and DEBUG=true as the text "true". The converter keeps them as strings so the JSON or YAML reflects exactly what your application will receive. Cast them in code where you read them.
Does it keep my comments?
Comments in .env files are read and then discarded during parsing. JSON and YAML have no equivalent inline comment position, so they cannot be carried into structured output.
Are quoted values handled?
Yes. Single and double quotes are stripped from values. Inside double-quoted values, standard escape sequences like \n, \t, and \\ are expanded, matching the behavior of the dotenv specification.
Is export KEY=value supported?
Yes. The export prefix is recognized and dropped. Keys with and without the prefix are treated identically.
Does my config leave the browser?
No. Parsing and conversion run entirely client-side. This matters because .env files often contain API keys, database passwords, and other secrets that should never be sent to a third-party server.
Related Tools
JSON / YAML to .env Converter
Convert a JSON or YAML config object into a .env file. Flattens nested keys, quotes values that need it, and outputs valid dotenv syntax.
YAML to JSON Converter
Parse YAML into JSON in your browser. Handles anchors, block scalars, and multi-line strings. Powered by js-yaml.
TOML to JSON Converter
Convert TOML to JSON. Reads Cargo.toml, pyproject.toml, and Hugo config files with full TOML type support.
JSON Formatter & Validator
Format, beautify, validate, and minify JSON. Detects BigInt precision issues, duplicate keys, and JSONC comments.