Skip to main content

Developer

YAML vs JSON — When to Use Which

Both formats represent structured data. JSON wins for APIs and serialization. YAML wins for human-edited config. The choice matters less than understanding the gotchas.

Try our JSON validator

JSON

Strict syntax no comments no trailing commas every string in double quotes. Universal browser/language support. Use for: APIs structured logging config files that are machine-edited or generated.

YAML

Indentation-significant supports comments allows multiple ways to express the same thing. Use for: config files humans edit (Kubernetes manifests GitHub Actions docker-compose CI configs).

YAML gotchas

Norway problem: 'NO' parses as false in YAML 1.1 — quote it. Octal numbers: '012' might parse as 10. Trailing whitespace silently breaks multi-line strings. Anchors and aliases (& *) are powerful but tank readability.

JSON gotchas

No comments — common workaround is a '_comment' field. Unicode strings need escaping. Trailing comma is invalid (annoying when reordering). Numbers without decimals lose precision in JS at 2^53.

Want to verify your setup?

Run the check now