JSON vs YAML
| JSON | YAML |
|---|---|
| |
YAML uses indentation instead of brackets, and quotes are optional. That makes it pleasant to write by hand, and easy to get subtly wrong.
Values that change meaning
Unquoted YAML values are guessed. The guesses differ between YAML 1.1 (PyYAML, Ruby, older Kubernetes tooling, many CI systems) and YAML 1.2. Converting YAML to JSON, the converter warns you about each risky value at its exact position:
| Unquoted value | YAML 1.2 reads | YAML 1.1 reads |
|---|---|---|
no, on, y | Text | Boolean |
012 | 12 | 10 (octal) |
22:30 | Text | 1350 (base 60) |
1.10 | 1.1 | 1.1 |
2026-11-13 | Text | A date object |
12345678901234567890 | A number too big for JSON to keep exactly | |
Converting JSON to YAML, turn on Safe for YAML 1.1 and any string that could be misread is quoted, so the YAML means the same thing to every parser.
Common YAML errors
- Tabs for indentation. YAML only allows spaces.
- Inconsistent indentation, so an item ends up under the wrong parent.
- No space after a colon:
key:valueis one string, not a key and value. - Duplicate keys, where the last one silently wins in many parsers.
- Unquoted special characters like
:or#inside a value.
Each is marked where it happens, in plain English, not as a parser stack trace.
Need JSON in another shape? Try JSON to CSV or JSON to TypeScript, or tidy it up with the JSON formatter.
Questions people ask
Is every JSON file valid YAML?
What is the Norway problem?
no, yes, on and off are booleans, so a list of country codes containing NO turns Norway into false. YAML 1.2 fixed this, but PyYAML, Ruby and many tools still use 1.1. With “Safe for YAML 1.1” on, the converter quotes these values.Why did my version number change from 1.10 to 1.1?
1.10 is a number in YAML, and numbers lose trailing zeros. Quote version numbers: version: "1.10". When converting YAML to JSON, the converter warns you about values like this.What happens to YAML comments and anchors?
&name, *name) and merge keys (<<) are expanded into full copies, because JSON can’t express references. The converter tells you when this happens.Can I convert a file with several YAML documents?
--- become a JSON array with one item per document, as you’d get from kubectl get -o yaml output or a multi-resource manifest.