YAML 1.2 is a superset of JSON; YAML 1.1 is not
Developers often treat JSON and YAML as interchangeable spellings of the same config file. Under YAML 1.2 that is nearly true: every JSON value — objects, arrays, strings, numbers, booleans and null — maps cleanly to YAML. The trouble is that older tooling (including Python's default PyYAML loader and many legacy Helm/CI pipelines) still implements YAML 1.1.
When you omit quotes in YAML, the parser decides the type from the token's shape. That convenience is where almost every cross-format config bug starts.
Five typing traps when converting
| YAML input | YAML 1.1 | YAML 1.2 | Safe practice |
|---|---|---|---|
| country: NO | false (boolean) | "NO" (string) | Quote country: "NO" if older YAML 1.1 tools also read the file. |
| enabled: yes | true (boolean) | "yes" (string) | Use true/false for booleans, or quote "yes" for a literal string. |
| version: 1.20 | 1.2 (float) | 1.2 (float) | Always quote versions and image tags: version: "1.20". |
| zip: 02134 | 1116 (octal int!) | 2134 (int) | Quote leading-zero codes: zip: "02134". |
| port: "8080" | "8080" (string) | "8080" (string) | Drop quotes when you want a number: port: 8080. |
# JSON input
{"service":"api","version":"1.20","enabled":"true","port":8080}
# Safe YAML 1.2 output (strings that look numeric or boolean stay quoted)
service: api
version: "1.20"
enabled: "true"
port: 8080Checking round-trips before you deploy
Tabs are forbidden for YAML indentation, and mixing two-space and four-space levels within the same mapping stops the parser. Whenever you edit a deployment manifest, run it through the JSON ↔ YAML converter and click Swap to confirm the round-trip returns identical types and values.
Comments, anchors and multi-document streams
#comment syntax (that is JSONC or JSON5 — see why JSON5 fails in strict parsers). Keep comments in a YAML source file rather than round-tripping through JSON.&defaultsand*defaultsare resolved before JSON emission, so every consumer receives the expanded object.---. A single-document YAML file converts to its root object; a multi-document file converts to a JSON array in file order.