YAML to .env Converter

Convert nested YAML to a flat .env file. Each nested key joins with an underscore and converts to UPPER_SNAKE. Useful when you have a structured config in YAML but need to load it via environment variables (12-factor app convention).

How to use the YAML to .env Converter

Paste YAML. Nested keys flatten with the chosen separator. Prefix prepends to every key (useful for namespacing in environments shared with other apps). Strings are quoted; numbers and booleans pass through unquoted.

Flattening YAML config into .env

Configuration reads well as nested YAML, but 12-factor apps and most container runtimes inject settings through flat environment variables, so a nested tree has to be flattened — each path joined into a single UPPER_SNAKE_CASE key — before it can be loaded as env vars.

This walks a YAML document and emits a .env file, joining nested keys with an underscore (or a double underscore for the Kubernetes and .NET convention) and optionally prefixing every key to namespace it. To go the other way and rebuild structure from a flat file, the env to YAML converter does that; for JSON output from a .env, the env to JSON converter.

Common use cases

  • 12-factor config — turn a YAML config into environment variables.
  • Container env — produce a .env for Docker or Compose.
  • Namespace keys — add a prefix to avoid collisions.
  • Kubernetes convention — use double-underscore separators for nesting.
  • Migrate formats — move a structured config to flat env vars.

Frequently asked questions

How are nested keys flattened?

Each level joins with the chosen separator and the whole key becomes UPPER_SNAKE_CASE.

What is the double-underscore option for?

It matches the Kubernetes and .NET convention for representing nested keys inside an env var name.

Can I namespace the keys?

Yes — set a prefix and it is prepended to every generated key.

How do I convert back?

Use the env to YAML converter to rebuild nested YAML from a flat file.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: