.env → Docker Compose
Paste a .env / dotenv file or upload one, then convert KEY=VALUE pairs into a
Docker Compose environment: block (YAML list or map). Optionally wrap a minimal
services.app snippet. Everything runs in your browser — nothing is sent to a server.
.env to Docker Compose controls
How it works
Paste a dotenv-style file or upload a .env / text file. The converter reads
KEY=VALUE lines, optional export prefixes, quotes, comments, and empty
values, then builds a Compose-ready environment: YAML block you can paste into
docker-compose.yml or Compose specs.
Choose list style (- KEY=value) or map style (KEY: value), decide whether
values with spaces or special characters are quoted, strip export, and optionally
wrap a minimal services.app snippet with a placeholder image.
Parsing is pure client-side JavaScript — handy when a .env has secrets you do not
want to post to a remote converter. Use Load sample to preview, then Clear when finished.
When to use this tool
- Moving local
.envexamples into a Composeenvironment:block - Standardizing on list vs map YAML style for your team’s Compose files
- Quickly scaffolding a minimal
services.appsnippet from existing env vars - Cleaning
export KEY=VALUEshell snippets before pasting into Compose
Tips
- Prefer offline tools for production secrets even though this page does not upload your paste
- For secrets in Compose, consider
env_file:or Docker secrets instead of inlining values - Pair with .env → JSON when you need JSON instead of YAML
- Replace
your-image:tagin the full snippet with your real image before deploying
Frequently asked questions
How do I turn a .env into Docker Compose environment variables?
Paste or upload your .env, choose list or map YAML style, then copy the generated environment: block into docker-compose.yml. Optionally wrap it in a minimal services.app snippet.
Does my .env leave my browser?
No. Parsing runs entirely in your browser with JavaScript. Your .env contents are not uploaded to a server. Prefer local tools for production secrets when possible.
List style vs map style — which should I use?
List style uses - KEY=value under environment: (common in Compose examples). Map style uses KEY: value. Both are valid in Docker Compose; pick the style your team already uses.
Is this .env to Docker Compose converter free?
Yes. The Formattly .env to Docker Compose converter is free to use with no signup required.
What does Full compose snippet do?
When enabled, output is wrapped in a minimal services.app block with a placeholder image and the environment: keys nested under it. When disabled, you get only the environment: block to paste into an existing service.