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 type | application/yaml | none (plain text) |
| Comments | yes (#) | yes (#) |
| Data types | JSON types plus dates, anchors and aliases | text only |
| Nesting | any depth, by indentation | none: flat keys |
| Typical use | Kubernetes, Docker Compose, CI pipelines | secrets and settings of apps, Docker, CI |
| Specification | YAML 1.2.2 | convention (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
- Paste your YAML in the input box (the page opens with an example you can replace).
- Read the .env on the right; it updates as you type. If something is wrong, the message says the line and column.
- Adjust the options if you need: indentation, sorted keys or type detection.
- Copy the result or download it as a
.envfile.
Example
This YAML input:
# orders service
app:
name: orders
port: 8080
database:
url: postgres://db:5432/orders
pool: 10
features:
- pix
- boletobecomes 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=boletoFrequently 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.