All Tools View Categories About Contact Privacy

.env to YAML Converter

Turn a .env file into a clean, typed YAML mapping — numbers, booleans, nested keys and all.

Runs entirely in your browser — nothing is uploaded.

About .env to YAML Converter

Your .env file is the source of truth on a laptop, but the moment configuration has to travel it usually has to change shape: a CI workflow wants a YAML mapping block, a Kubernetes ConfigMap is YAML by definition, Compose users hand-write environment: blocks, and GitLab or GitHub Actions runners read env from YAML. Manually transcribing KEY=value lines into YAML is slow and quiet dangerous — an unquoted 8080 is fine, but an unquoted yes becomes a boolean, a value containing : silently truncates, and a value starting with a special character can break the whole mapping.

The .env to YAML Converter does the translation in one click. Paste your .env, choose how deep to go, and get a valid, prettified YAML mapping ready for any tool that consumes structured config. Numbers, booleans and null arrive as real YAML types instead of quoted strings. Nested keys such as FEATURE__DARK_MODE expand into indented child mappings, or you can keep everything flat. Values that would confuse the YAML parser are double-quoted with correct escaping, while plain values stay readable.

Everything runs locally in your browser — secrets never leave the page, quoted values are unwrapped correctly, duplicate keys are flagged with their line numbers, and both 2-space and 4-space indentation are one dropdown away.

Features

  • One-click conversion: paste .env, get valid prettified YAML.
  • Type-aware values: numbers, booleans and null are detected automatically.
  • Nested mappings: expand FOO__BAR into indented child objects with a configurable separator.
  • Smart quoting: values that would break YAML are double-quoted; plain values stay readable.
  • Correct escaping: embedded quotes and backslashes are escaped with \" and \\.
  • Quote unwrapping: single- and double-quoted .env values are resolved before conversion.
  • Indentation control: 2 or 4 spaces, matching your project style.
  • Duplicate detection: repeated keys are reported with their line numbers.
  • Comments & blanks: # lines and empty lines are skipped cleanly.
  • Copy / download: clipboard or a .yaml file in one click.
  • Private: all conversion happens in your browser.

How to Use

  1. Paste your .env content into the input box, or click Load sample to see a realistic example with typed values and nested keys.
  2. Choose your options. Toggle type detection and nested keys, set the separator (default __), pick 2 or 4-space indentation, and optionally sort keys A-Z.
  3. Click Convert. The YAML mapping appears instantly on the right.
  4. Review the stats — variables converted, comments skipped, any duplicate warnings.
  5. Copy or download the result as a .yaml file for your workflow, ConfigMap or pipeline.

Examples

Example 1 — GitHub Actions workflow. A developer converts APP_NAME, PORT and DEBUG into YAML for the env: block of a workflow. With type detection on, PORT stays a number and DEBUG becomes a real boolean that shell steps can test directly.

Example 2 — Kubernetes ConfigMap. An operator pastes the contents of a .env into this tool and pastes the resulting mapping into the data: block of a ConfigMap. Nested keys become indented objects, matching how kubectl and helm expect structured config.

Example 3 — Nested feature flags. FEATURE__DARK_MODE=true and FEATURE__ANALYTICS=false become a two-key child mapping under FEATURE:, exactly the shape a config-management UI or templating engine wants.

Example 4 — GitLab CI variables. A platform engineer copies the generated YAML into variables: of a .gitlab-ci.yml so CI and local development read the same values from the same source.

Example 5 — Docker Compose. A team member converts DATABASE_URL and API_KEY lines to YAML to paste under environment: in a compose service, avoiding shell-quoting bugs in the compose file.

Benefits

  • No transcription errors: the YAML is derived from your .env, not retyped.
  • Correct types: numbers, booleans and null arrive as real YAML types.
  • Structured keys: nested mappings match ConfigMap, Compose and CI conventions.
  • Safe quoting: DATABASE_URL and API_KEY values with special characters parse cleanly.
  • Duplicate warnings: find conflicting keys before a pipeline silently uses the wrong one.
  • Private & free: no upload, no account, instant results.

Frequently Asked Questions

What does this tool do?
It takes a standard .env file with KEY=value lines and produces an equivalent YAML mapping. Values become the right YAML types — numbers stay numbers, true/false become real booleans, null becomes null — and keys separated by __ can be expanded into nested objects, just like a structured config file.
Why would I need .env as YAML?
Many tools want YAML: GitHub Actions workflows, GitLab CI, Kubernetes ConfigMaps and Secrets, Docker Compose, GitHub-hosted config services, and any pipeline that expects structured configuration. Hand-converting is slow and the quoting rules are easy to get wrong.
How does type detection work?
A value is treated as a number only if it round-trips exactly under String(Number(v)) === v, so 8080 becomes 8080 but 007 or 5.50 stay strings. The words true, false and null map to their real YAML types; everything else stays a string.
How do nested keys become nested YAML?
When the Nested keys option is on, a key like FEATURE__DARK_MODE is split on the separator (default __) and expanded into a real nested mapping with indentation. Turn it off and every key stays flat, which is useful when a target tool does not expand separators.
When are values quoted?
A value is double-quoted only when YAML would misread it: leading special characters, a colon followed by a space, a hash preceded by a space, a trailing colon or space, a value containing quotes or backslashes, or a reserved word such as yes, no, on, off, null. ASCII-safe plain scalars stay readable and indentation is preserved.
What about quotes inside values?
Values wrapped in single or double quotes are unwrapped first, and when the output needs quotes, embedded quotes and backslashes are escaped with \" and \\ so the YAML parses back to the exact original value.
Are my secrets uploaded?
No. Parsing and conversion run entirely in your browser. Nothing is sent to a server, stored or logged.
How do I convert YAML back to .env?
Use the YAML to .env Converter in this same tool family. Paste the YAML mapping and you get .env lines back, including nested objects re-flattened with the separator.