YAML to .env Converter
Convert YAML configuration files to .env environment variable format. Flattens nested keys to UPPER_SNAKE_CASE and handles strings, numbers, booleans, and arrays.
About YAML to .env Conversion
Modern applications often store configuration in YAML files for human readability, but deployment environments (Docker, Kubernetes, cloud platforms) expect environment variables. This converter bridges that gap by flattening nested YAML structures into UPPER_SNAKE_CASE environment variable names. For example, database.host: localhost becomesDATABASE_HOST=localhost. Arrays are joined as comma-separated values. The conversion happens entirely in your browser — no data is sent to a server.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Producing environment variables from a YAML config for a container platform.
- Flattening nested YAML keys into upper snake case for a twelve-factor app.
- Generating a local `.env` from a checked-in YAML template.
- Converting configuration for a target that only reads environment variables.
- Comparing a YAML config against an existing environment file.
Frequently Asked Questions
- How do nested keys become variable names?
- They are flattened with underscores and upper-cased: `database.host` becomes `DATABASE_HOST`. Any character outside A–Z and 0–9 becomes an underscore too, since that is the portable character set for an environment variable name across shells, Docker and Kubernetes.
- What happens to a YAML list?
- It is joined with commas — `tags: [api, web]` becomes `TAGS=api,web`. The environment is a flat string-to-string map with no concept of a list, so structure has to be encoded into the value and re-split by the application. A value that already contains a comma cannot round-trip.
- Does the .env output need quotes?
- Not for simple values, but be careful with anything containing spaces, a `#`, or a newline. Docker Compose, `docker run --env-file` and the various dotenv libraries all disagree about quoting and comment handling, so a value that works in one loader can silently truncate in another.
- Are types preserved?
- No — everything becomes a string, because that is all an environment variable can hold. `debug: false` becomes `DEBUG=false`, the five characters. Code that then does `if (process.env.DEBUG)` sees a truthy non-empty string, which is among the most reliably recurring config bugs there is.
- Is it safe to paste a config containing credentials?
- The conversion runs entirely in your browser and nothing is transmitted. The tool also flags values that look like secrets — the point being that a `.env` generated from a config file is exactly the artefact people accidentally commit, so it helps to know which lines matter before saving it.
Common errors and gotchas
- Committing the result, which typically holds secrets and is gitignored for that reason.
- Losing types that YAML inferred, since every environment variable is a string.
- Flattening an array with no agreed separator, leaving the consumer to guess.
- Producing names that are not valid environment identifiers after the case conversion.
- Emitting a multi-line block scalar as a value, which most environment parsers cannot carry.