Docker Compose · Configuration · DevOps
YAML Docker Compose — Convert to JSON
Updated: May 2026
The docker-compose.yml file is the central config for your multi-container Docker deployments. Converting it to JSON lets you debug it, document it, pass it to a validation tool, or integrate it into an infrastructure as code pipeline.
Convert docker-compose.yml →
Free · No upload · Browser-based
Example docker-compose.yml
version: "3.9"
services:
web:
image: nginx:alpine
ports:
- "80:80"
depends_on:
- db
environment:
NGINX_HOST: example.com
db:
image: postgres:15
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: secret
volumes:
pgdata:
This file converts to a structured JSON object with services, volumes, and networks correctly nested.
Common use cases
- Debug a complex
docker-compose.ymlby inspecting its parsed JSON structure. - Validate against a JSON Schema to catch errors before deployment.
- Integrate the config into an IaC tool that expects JSON input.
- Compare two Compose file versions with a JSON diff.
- Generate automated documentation from the config structure.
Docker Compose YAML specifics
- Quoted ports:
"80:80"in quotes to prevent YAML from interpreting it as a sexagesimal integer. - Environment variables: can be list or mapping format — both are supported.
- Named volumes: defined with empty values (
pgdata:) becomenullin JSON — this is expected behavior. - Extensions (
x-): Docker Compose extension keys are converted as regular keys.
Frequently asked questions
Are ${ENV_VAR} variables resolved?
No. Environment variable references remain as literal strings. Resolution happens at Docker runtime.
My Compose file uses YAML anchors (&default) — is that supported?
Simple anchors and aliases are partially supported. Merge keys (<<: *default) may not be fully resolved.
Can I convert the JSON back to a docker-compose.yml?
Yes. Copy the generated JSON, switch to JSON → YAML mode, and convert. The resulting YAML is equivalent to the original.