Environment Variable Parser
Parse .env files and convert between ENV, JSON and YAML with type coercion and validation.
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
KEY=value— simple assignment-
export KEY=value— shell-style export prefix is stripped -
KEY="quoted value with spaces"— double quotes preserved withand"escapes KEY='single quoted'— literal value, no escapes-
KEY=value # inline comment— comments after a value # full line comment— ignored- Empty lines — ignored
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
-
Migrating from Heroku to Vercel — paste
heroku config -soutput, get JSON forvercel env. -
Bootstrapping a Kubernetes ConfigMap — convert
.envto YAML and paste underdata:. - Auditing a config file — convert ENV to JSON and diff two environments with our JSON Diff.
-
Generating a
.env.example— convert JSON back to ENV with sensible defaults.
What this tool does NOT do
-
It does not interpolate variables (
FOO=$BAR). Real dotenv libraries support this; we keep the literal value to avoid surprising you. -
It does not load
.env.localoverride chains or merge files. -
It does not encrypt secrets. If you're putting an API key in
.env, treat the file as sensitive — and don't paste it into random websites that send it to a server. (Ours doesn't.)
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.