YAML to .env

Paste YAML and get .env at once, with errors pointed by line and column, then copy or download the result.

loading YAML to .env
About this tool

What are YAML and .env?

YAML describes the same data as JSON with indentation instead of brackets, allows comments and is the language of most configuration files. A .env file holds environment variables as KEY=value lines, one per line; frameworks and Docker load it into the process environment at startup.

The reverse of the Compose and Kubernetes case: run locally what a YAML config describes, with the same values as plain KEY=value lines.

This page opens the data converter already set to YAML → .env. Paste the text, read the result as you type, then copy it or download it as a file. Errors show the line and the column. Nothing is sent anywhere: the conversion runs in your browser.

YAML vs .env

YAML.env
Extension.yaml, .yml.env
Media typeapplication/yamlnone (plain text)
Commentsyes (#)yes (#)
Data typesJSON types plus dates, anchors and aliasestext only
Nestingany depth, by indentationnone: flat keys
Typical useKubernetes, Docker Compose, CI pipelinessecrets and settings of apps, Docker, CI
SpecificationYAML 1.2.2convention (no formal spec)

When to convert YAML to .env

  • Convert to .env when the values go into environment variables of an app or a container.
  • Keep YAML when people will read and edit the file by hand.

What changes in the conversion

  • Comments of the YAML file are not carried over: the converter reads the data, and comments are not data.
  • Nested keys are joined with _ and upper-cased (database.url → DATABASE_URL), list items get their index (FEATURES_0), and values with spaces or symbols are quoted.
  • Anchors and aliases (&base, *base) are expanded into full copies.

How to convert YAML to .env

  1. Paste your YAML in the input box (the page opens with an example you can replace).
  2. Read the .env on the right; it updates as you type. If something is wrong, the message says the line and column.
  3. Adjust the options if you need: indentation, sorted keys or type detection.
  4. Copy the result or download it as a .env file.

Example

This YAML input:

# orders service
app:
  name: orders
  port: 8080
database:
  url: postgres://db:5432/orders
  pool: 10
features:
  - pix
  - boleto

becomes this .env, exactly as the converter writes it:

APP_NAME=orders
APP_PORT=8080
DATABASE_URL=postgres://db:5432/orders
DATABASE_POOL=10
FEATURES_0=pix
FEATURES_1=boleto

Frequently asked questions

Is my YAML sent to a server?

No. Conversion happens in your browser, so secrets in a config never leave your computer.

Does YAML to .env keep comments?

No. Comments are dropped because the converter works on the data itself. Copy important comments by hand.

What happens to nested data?

YAML nesting: any depth, by indentation. .env nesting: none: flat keys. The tree is flattened into one key per value, as shown in the example.

Report a problem