By Docify

YAML 1.2 Core vs 1.1: Norway, Comments, JSON

• 6 min read

YAML 1.2 Core (the schema js-yaml 5 load uses here) treats yes and NO as strings. YAML 1.1’s boolean type would turn NO into false — the Norway problem (ISO 3166-1 alpha-2). Comments never survive load. Core .inf is JavaScript Infinity, then JSON.stringify writes null. Not a pretty-printer and not Kubernetes validation. Nothing is uploaded.

The same YAML bytes can mean different native values depending on the schema. The live YAML converter parses one document with js-yaml 5 CORE_SCHEMA (YAML 1.2 Core, spec §10.3). This page names what that schema keeps as text, what YAML 1.1 used to coerce, and what a JSON round trip must drop — comments first.

Implicit types: 1.2 Core vs 1.1

Booleans: Norway is a string in Core

YAML 1.2.0 (2009-07-21) made Core the recommended default. Spec 10.3.2 resolves only true / True / TRUE and false / False / FALSE. YAML 1.1 !!bool (2005-01-18) also accepted yes / no / on / off and the single letters y / n in a fixed list of capitalizations. Norway’s country code NO is on that list, so a 1.1 loader turns it into false. The live converter leaves it as the two characters N and O. nO was never a 1.1 boolean.

country: NO → { "country": "NO" } (Core) · false (YAML 1.1)

Integers: 0o octal, no sexagesimal

Core integers are decimal [-+]?[0-9]+, octal 0o[0-7]+, and hex 0x[0-9a-fA-F]+. A leading zero is still decimal: 010 is 10 and 0777 is 777. YAML 1.1 !!int treated a leading 0 as octal (010 → 8, 0777 → 511), allowed 0b binary and _ separators, and parsed sexagesimal 1:30:00 as 5400. Core keeps that colon form as a string. 1.2.2 (2021-10-01) did not change these rules.

0o10 → 8 · 010 → 10 · 1:30:00 stays "1:30:00"

Dates stay strings; << is a key

YAML 1.1 !!timestamp resolved a date-only value such as 2026-08-20 to midnight UTC. Core dropped that type, so the live load returns the hyphenated string. The 1.1 merge key << and value key = were removed in 1.2; here << is just a mapping key. Duplicate keys throw. Extra --- documents throw. Empty input throws “expected a document”.

What a JSON round trip cannot keep

Comments are presentation, not data

Spec 3.2.3.3 puts comments in the presentation stream. They are not nodes. After load, the in-memory value is a plain object or array. dump writes CORE_SCHEMA YAML with 2-space indent, unlimited line width, and noRefs: true so a shared object is inlined twice instead of &anchor / *alias. Quote style and key order are not a formatter guarantee. Convert is a button, not as-you-type.

name: Docify # kept? → { "name": "Docify" }

.inf and .nan become JSON null

Core still types .inf and .nan as floats. In the browser those are Infinity and NaN. JSON.stringify (ECMA-262) serializes a non-finite Number as null. JSON → YAML then uses JSON.parse, so a later dump sees JSON null and writes YAML null, not .inf. Trailing commas and single-quoted JSON are rejected on that path. This is not a YAML 1.1 boolean change.

Convert one YAML 1.2 Core document

yes / NO stay strings. Comments do not. Nothing is uploaded.

Use YAML to JSON →

FAQ

What is the Norway problem?
YAML 1.1’s !!bool type (yaml.org/type/bool.html, 2005-01-18) resolves y, Y, yes, Yes, YES, n, N, no, No, NO, true/false, and on/off in those spellings. Norway’s ISO 3166-1 alpha-2 code is NO, so a country list that writes NO becomes boolean false. YAML 1.2 Core (spec 10.3.2, revision 1.2.0 on 2009-07-21) keeps only true/True/TRUE and false/False/FALSE as booleans. js-yaml 5 load with CORE_SCHEMA therefore leaves yes and NO as strings. nO is not in the 1.1 regex and was already a string.
Why do comments disappear after Convert?
YAML comments (# to the end of the line) live in the presentation stream (spec 3.2.3.3), not in the representation graph. load builds maps, sequences, and scalars and discards comments. dump then writes new CORE_SCHEMA text with 2-space indent. A round trip cannot restore a comment, a discarded --- document, or the original quote style. This is not a comment-preserving pretty-printer.
Why does .inf become null in the JSON output?
YAML 1.2 Core still resolves .inf / -.Inf / +.INF and .nan / .NaN / .NAN as floats (Infinity and NaN in JavaScript). JSON has neither. ECMA-262 JSON.stringify turns a non-finite Number into null, so the live converter’s JSON.stringify(..., null, 2) writes null. That is a JSON limit, not a YAML 1.1 vs 1.2 boolean change. ~ and null still become JSON null on purpose.
Does this page parse YAML 1.1, merge keys, or Kubernetes YAML?
No. load uses CORE_SCHEMA only. << is an ordinary key (1.2 removed the merge key). 2026-08-20 stays a string because Core dropped !!timestamp. 010 is decimal 10 (octal needs the 0o prefix). 1:30:00 stays a string (sexagesimal integers were dropped). Duplicate keys and extra --- documents throw. This is not PyYAML’s 1.1 defaults, not a Helm/Kubernetes validator, and not a JSON Schema linter.

Related