What this does
Paste a flat YAML mapping (KEY: value pairs — a Helm values.yaml section, a Kubernetes ConfigMap's data:, a GitHub Actions env: block) or a Docker Compose-style list of "KEY=VALUE" strings, and get back a .env file. It's the mirror of .env to YAML, sharing the same design goal: the output should be safe by construction, not just correct for the example you tried.
Every value is written double-quoted, always — PORT: 3000 becomes PORT="3000", not the bare PORT=3000 you might write by hand. This isn't just style: an unquoted .env value is truncated at the first unescaped # (real dotenv behavior, not a hypothetical), so any YAML value that happens to contain one — a URL fragment, a generated password — would come out silently corrupted without the quotes. Quoting unconditionally means nothing this tool outputs can hit that trap.
Comments written directly above a YAML key are carried over as # lines above the matching KEY=VALUE line, and a trailing inline comment is preserved too. Numbers, booleans, and null are converted to their plain string form (null becomes an empty value), matching how they'd actually be read back once loaded into process.env, where everything is a string regardless of how it was written in YAML.
What it doesn't do
A nested object or list value has no single obvious .env equivalent, so rather than guess at a flattening convention this tool doesn't expect, those keys are skipped with a warning explaining why. A key containing spaces, =, or quote characters can't be written as a valid .env key at all and is skipped the same way. Exact blank-line spacing between entries isn't preserved when there isn't also a comment there — YAML doesn't attach that whitespace to anything that survives parsing.
FAQ
Why does PORT: 3000 need quotes at all — isn't 3000 obviously a number?
It's a number in the YAML, but .env values are always strings once they're loaded — there's no way to write a "numeric" environment variable. The quotes in the output reflect what the value actually becomes at runtime, and also happen to be the only fully safe way to write it (see the #-truncation point above).
My YAML has a nested config section — how do I convert that?
Flatten it in the YAML first, using whatever prefix convention your application expects (e.g. database.host becomes a top-level DATABASE_HOST key) — this tool intentionally doesn't invent that convention for you, since different frameworks expect different flattening schemes.