YAML to ENV Converter — Free Online
YAML to .env Converter
Paste YAML configuration and get a .env file: one KEY="value" line per setting, ready for dotenv, Docker --env-file or a CI pipeline. Conversion runs in your browser; nothing is uploaded.
How the conversion works
- Nested keys are joined with underscores and uppercased:
database.hostbecomesDATABASE_HOST. - List items get an index suffix:
replicas: [db2, db3]becomesDATABASE_REPLICAS_0andDATABASE_REPLICAS_1. - Names are always valid variable names. Characters other than letters, digits and
_(such as-inmy-app) become_. - Values are double-quoted, with
",\, tabs and line breaks escaped, so values with spaces and special characters survive. - Values containing
$are single-quoted so dotenv-expand and Docker Compose do not expand them. - Nothing is dropped: dates are kept as text, and empty
{}/[]are written as the literal values. Colliding names are reported in a# warning:comment at the top. - Multi-document YAML is rejected with a clear message — convert one document at a time.
- The Options bar sets key case, separator (
_or__), a prefix such asAPP_, and quoting. nullbecomes an empty value:KEY=.
Example
app:
name: demo
port: 8080
debug: true
database:
host: localhost
replicas:
- db2
- db3becomes
APP_NAME="demo"
APP_PORT="8080"
APP_DEBUG="true"
DATABASE_HOST="localhost"
DATABASE_REPLICAS_0="db2"
DATABASE_REPLICAS_1="db3"When to use it
- Twelve-factor apps that read configuration from environment variables but keep defaults in YAML.
- Docker and Compose —
docker run --env-file .envor theenv_file:key. - CI/CD — generate variables for GitHub Actions, GitLab CI or a deploy script from a YAML source of truth.
Reading lists back
Environment variables are flat strings, so a list arrives as numbered variables. Collect them in your app (for example every variable starting with DATABASE_REPLICAS_), or store the list as a single comma-separated value instead if your app expects that.
Related tools
- .env to YAML — the reverse direction
- YAML to Bash —
exportstatements for a shell script - JSON to .env