How to use the YAML Formatter
- Pick a mode: "Format YAML", "YAML → JSON" or "JSON → YAML".
- Paste your content on the left, or press "Sample" to load a Docker Compose example.
- The result appears on the right; on a syntax error the status bar shows the line and column.
- Press "Copy" or "Download" to get the result.
Examples
YAML to JSON
services:
web:
image: nginx:1.27
ports:
- "80:80"
{
"services": {
"web": {
"image": "nginx:1.27",
"ports": [
"80:80"
]
}
}
}
Most common YAML mistakes
- Tabs for indentation: YAML only accepts spaces; a tab is an error.
- Inconsistent indentation: keys at the same level must line up — one space more or less changes the structure.
- No space after the colon:
key:valuebecomes a string; writekey: value. - Unquoted special characters: quote values that start with
*,&or@, or contain:. - yes / no / on / off: YAML 1.1 parsers read these as booleans; quote them to keep strings.
Specs & key facts
| Spec | YAML 1.2 (powered by js-yaml 4.3) |
|---|---|
| Modes | Format YAML, YAML → JSON, JSON → YAML |
| Indentation | 2 or 4 spaces |
| Errors | Line and column of the error |
| Processing | In your browser (nothing is uploaded) |
| Price | Free, no sign-up |
FAQ
What is the difference between YAML and JSON?
YAML uses indentation and supports comments, which makes it pleasant for hand-edited config files; JSON uses braces and brackets with strict syntax, which suits data exchange between programs. YAML 1.2 is a superset of JSON, so every valid JSON document is valid YAML.
Are comments kept after conversion?
No. Comments are not part of the data, so they are dropped when converting or reformatting.
Can it validate Kubernetes or Docker Compose files?
It validates YAML syntax, but it does not check whether Kubernetes or Compose field names and values follow their schemas.
What about files with multiple documents (---)?
Only the first document is processed. Paste multiple documents separately.