Use compose.yaml
It is the preferred file name. docker-compose.yml still works for older projects.
Generate a valid compose.yaml from JSON, with ports and environment values quoted safely.
Each line of the output, in default formatting, next to the path of the value it holds. Click a row to copy the path.
Runs entirely in your browser, so nothing is uploaded. Fair-use limits apply (5 MB per input, rate-limited conversions) to prevent spam and bots.
Compose files are read by YAML 1.1 parsers, where 22:22 is a base-60 number and NO is false. Every ambiguous string is quoted so services start with the values you wrote.
{
"services": {
"web": {
"image": "nginx:1.27",
"ports": [
"80:80",
"22:22"
],
"environment": {
"DEBUG": "false",
"WORKERS": "4",
"COUNTRY": "NO"
}
}
}
} services:
web:
image: nginx:1.27
ports:
- '80:80'
- '22:22'
environment:
DEBUG: 'false'
WORKERS: '4'
COUNTRY: 'NO' Keep YAML 1.1 safe on for Compose files. Turn it off above to see 22:22 written unquoted, and what a YAML 1.1 parser makes of it.
docker compose config validates the file and prints the final model, and it can print that model as JSON as well.
# Validate a compose file and print the fully resolved model
docker compose config
# The same model as JSON, e.g. to inspect it with jq
docker compose config --format json | jq '.services | keys' It is the preferred file name. docker-compose.yml still works for older projects.
The top-level version field is obsolete; current Docker Compose ignores it and prints a warning.
environment accepts a map (KEY: value) or a list (- KEY=value). Maps from JSON objects are easier to read.
Converters, validators and step-by-step guides for every place JSON and YAML meet.
Paste the JSON into the editor and copy the YAML on the right into compose.yaml. Keep the top-level services, volumes and networks keys, then run docker compose config to check the result.
YAML 1.1 parsers read unquoted numbers separated by colons, such as 22:22, as base-60 integers. Docker recommends always quoting port mappings, and the converter does it for you while "YAML 1.1 safe" is on.
compose.yaml is the preferred name in the current Compose specification; docker-compose.yml and docker-compose.yaml are still read for backward compatibility.
No. The top-level version key is obsolete in the Compose specification and Docker Compose ignores it, printing a warning. You can leave it out.
Yes. Switch the direction to YAML → JSON, or run docker compose config --format json, which also resolves variables, extends and profiles.