JSON to Docker Compose YAML

Generate a valid compose.yaml from JSON, with ports and environment values quoted safely.

Output options

JSONinput

Empty

YAMLoutput

YAML output appears here

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.

Load from URL

The file is fetched directly by your browser, so the server must allow cross-origin requests.

Keyboard shortcuts

Ctrl / ⌘ + Enter Convert now
Ctrl / ⌘ + S Download the output
Alt + Shift + C Copy the output
Alt + Shift + F Fix and format the JSON input
Alt + Shift + S Swap direction
Alt + Shift + T Cycle through code, tree and map views
Ctrl / ⌘ + Z Undo, including Format, Fix and Clear
Esc Leave full screen
Editor text size

Ports and environment values, quoted safely

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.

JSON
{
  "services": {
    "web": {
      "image": "nginx:1.27",
      "ports": [
        "80:80",
        "22:22"
      ],
      "environment": {
        "DEBUG": "false",
        "WORKERS": "4",
        "COUNTRY": "NO"
      }
    }
  }
}
compose.yaml
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.

Check the result with Docker

docker compose config validates the file and prints the final model, and it can print that model as JSON as well.

bash
# 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'

Compose tips

Use compose.yaml

It is the preferred file name. docker-compose.yml still works for older projects.

Drop the version key

The top-level version field is obsolete; current Docker Compose ignores it and prints a warning.

Lists or maps for env

environment accepts a map (KEY: value) or a list (- KEY=value). Maps from JSON objects are easier to read.

More tools

Converters, validators and step-by-step guides for every place JSON and YAML meet.

Frequently asked questions

How do I convert JSON to a Docker Compose file?

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.

Why are port mappings like "80:80" quoted?

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.

Should the file be called compose.yaml or docker-compose.yml?

compose.yaml is the preferred name in the current Compose specification; docker-compose.yml and docker-compose.yaml are still read for backward compatibility.

Do I still need the version key?

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.

Can I convert a compose file back to JSON?

Yes. Switch the direction to YAML → JSON, or run docker compose config --format json, which also resolves variables, extends and profiles.