How to convert YAML to JSON
- Paste your YAML into YAML, for example a Docker Compose file or a CI workflow.
- Choose Indented for readable JSON or Minified for a single line.
- Copy or download the JSON. If the YAML has a mistake, the status line names it with the line and column.
How YAML values become JSON
| YAML | JSON |
|---|---|
image: nginx:1.27-alpine |
"image": "nginx:1.27-alpine" |
port: 8080 |
"port": 8080 |
version: 1.10 |
"version": 1.1 |
enabled: true |
"enabled": true |
country: NO |
"country": "NO" |
retries: ~ |
"retries": null |
released: 2024-05-01 |
"released": "2024-05-01" |
Block text after | or > |
One string with \n line breaks |
Values are read as YAML 1.2, so words like yes, no, on and NO stay strings. In YAML 1.1 tools they would be booleans. A | block keeps the line breaks, while > joins the lines with spaces, which is why the worker command in the example becomes one line.
Common YAML errors
- Tabs used for indentation. YAML only accepts spaces, and a tab gives “Tabs are not allowed as indentation”.
- Uneven indentation. Keys at the same level must start in the same column.
- Repeated keys. The same key twice in one mapping is an error, not a silent overwrite.
- A missing space after the colon.
key:valueis not a key and a value. YAML needskey: value.