Home · Tools · Environment Variable Parser

Environment Variable Parser

Parse .env files and convert between ENV, JSON and YAML with type coercion and validation.

From:
Input
Output empty

Convert .env files to JSON, YAML and back

This converter parses .env files, JSON, and YAML and converts between all three formats. It handles quoted values, comments, the optional export prefix, escaped newlines, and automatic type coercion (booleans, integers, floats). Run it on a 12-factor app config, a Docker Compose environment: block, or a GitHub Actions env: section without rewriting the values by hand.

Why a dedicated parser beats find-and-replace

You can almost convert ENV to JSON with regex, but you'll trip on the edge cases: a value containing =, a multiline string with escapes, a comment after a value, an export FOO=bar line, or a value wrapped in single quotes. A real parser handles all of those, plus it tells you the line number when something is wrong instead of silently producing garbage.

Supported ENV syntax

Type coercion

When converting ENV to JSON or YAML, common literals are coerced: true/false become booleans, integers become numbers, decimals become floats. Everything else stays a string. This is what 12-factor configuration libraries (dotenv, Viper, python-decouple) do, so the output matches what your app would actually see at runtime.

Use cases

What this tool does NOT do

Privacy

Parsing happens in JavaScript on this page. Nothing is uploaded. We deliberately avoided libraries that would phone home and we don't load any third-party scripts.

Related tools

FAQ

Does this handle multiline values?
Yes — values inside double quotes can include \n which is converted to a real newline. Values inside single quotes are kept literal.
Will it expand variables like FOO=$BAR?
No, the value is kept literally. Variable expansion is dotenv-library specific behavior and would be unsafe to apply blindly.
Is YAML support full YAML 1.2?
No, it's a flat YAML parser intended for env-style configuration (nested maps and scalars). Anchors, tags, and complex structures are not supported.
How are types inferred when converting ENV to JSON?
true/false become booleans, integers become numbers, decimals become floats. Everything else stays a string — matching how 12-factor config libraries behave.
Can I convert .env to a Kubernetes ConfigMap?
Convert ENV to YAML here, then paste the result under the data: field of your ConfigMap (remembering Kubernetes wants string values, not booleans/numbers — wrap them in quotes).