About this tool
Convert .env entries into docker-compose environment blocks (list or map form) or env_file references, with $$ escaping.
This tool converts .env entries into a docker compose environment block, in either of the two syntaxes the Compose Specification defines: the list form (- KEY=value) or the map form (KEY: value). It escapes literal dollar signs as $$ so compose interpolation cannot mangle values, quotes YAML-ambiguous scalars like NO, true and 3000, and can emit an env_file reference when you would rather keep values out of the compose file.
Open Env to Compose Environment Converter on AltFTool — it loads instantly in your browser.
Paste or upload your source content.
Choose the target format or conversion mode.
Copy or download the converted result.
Generates the exact list or map form defined in the Compose Specification services element.
Literal $ becomes $$, the documented escape that stops compose from substituting ${VAR} patterns.
Values YAML 1.1 would reparse — NO, true, off, 3000, 1.10 — are quoted so they stay strings.
Both are equivalent per the Compose Specification, so it is a style choice: the list form (- KEY=value) looks like .env lines, while the map form (KEY: value) is easier to merge across override files. The map form needs more care with quoting, since unquoted values like NO or 3000 are parsed by YAML as boolean and number.
Compose interpolates ${VAR} and $VAR patterns in the compose file itself before starting containers. To pass a literal dollar sign through — common in password hashes and cron-like strings — the Compose spec requires doubling it: pa$$word in the file yields pa$word in the container. This tool applies that escape automatically.
environment inlines the variables in docker-compose.yml, where they are visible in version control and to anyone reading the file; env_file points at an external file that is loaded at container start and can stay gitignored. Values set in environment take precedence over the same keys from env_file.
Because YAML 1.1, which compose parsers historically follow, reads unquoted NO as the boolean false — the well-known Norway problem. The same applies to yes, on, off, null and bare numbers, so the tool double-quotes any value that would change type when unquoted.
Add the Env to Compose Environment Converterwidget to your blog or website — free, responsive, no signup. Just keep the “Widget by AltFTool” credit link visible.
<iframe src="https://www.altftool.com/embed/widget/env-to-compose-environment-converter"
title="Env to Compose Environment Converter — free AltFTool widget"
width="100%" height="640" style="border:0;border-radius:12px;overflow:hidden"
loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p style="font-size:12px;margin:4px 0 0">Widget by <a href="https://www.altftool.com/tools/all/env-to-compose-environment-converter?utm_source=embed&utm_medium=widget">AltFTool — free online tools</a></p>