YAML to .env converter

Useful for moving settings from a YAML file into environment variables for Docker containers or hosting platforms that read .env files.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter yaml text, level separator and upper_case names.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

YAML is read with the YAML 1.2 core schema, then each value's path is joined with the chosen separator, so database.host becomes DATABASE__HOST. Characters not allowed in names become _, values with spaces or symbols get single quotes, and values with line breaks get double quotes with \n.

Example

Inputs: Level separator = Double underscore __, UPPER_CASE names = yes. Result: .env: APP=toolsahla PORT=8080 DEBUG=false LANGUAGES__0=ar LANGUAGES__1=en DATABASE__HOST=localhost DATABASE__USER=admin WELCOME="Welcome to ToolSahla\nأهلا بك\n" ; Variables: 8.

# App settings
app: toolsahla
port: 8080
debug: false
languages:
  - ar
  - en
database:
  host: localhost
  user: admin
welcome: |
  Welcome to ToolSahla
  أهلا بك
APP=toolsahla
PORT=8080
DEBUG=false
LANGUAGES__0=ar
LANGUAGES__1=en
DATABASE__HOST=localhost
DATABASE__USER=admin
WELCOME="Welcome to ToolSahla\nأهلا بك\n"

Limits and caveats

  • The tool supports a clear YAML subset: maps, lists, scalars, quoted strings, | and > block scalars and [ ] and { } flow collections. Anchors &, aliases *, tags ! and multiple documents are rejected with a clear message.
  • Every value becomes text, and lists become numbered variables such as LIST__0.

Questions about this tool

Does the output work with docker run --env-file?

Yes for simple values. Note that this Docker option keeps quotes literally, unlike Docker Compose.

How is a list written?

Each item becomes a numbered variable such as LANGUAGES__0 and LANGUAGES__1.

Does it change the case of values?

No. Upper case applies to variable names only.