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.host becomes DATABASE_HOST.
  • List items get an index suffix: replicas: [db2, db3] becomes DATABASE_REPLICAS_0 and DATABASE_REPLICAS_1.
  • Names are always valid variable names. Characters other than letters, digits and _ (such as - in my-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 as APP_, and quoting.
  • null becomes an empty value: KEY=.

Example

app:
  name: demo
  port: 8080
  debug: true
database:
  host: localhost
  replicas:
    - db2
    - db3

becomes

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 .env or the env_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.