npm / yaml
yaml
What changed in yaml 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
15 breaking1 security1 deprecations17 new APIs and options3 behavior and defaults1 tooling13 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli inityaml 251 changes
Breaking changes 15
Recursive merge aliases are limited, changing how YAML documents with recursive merge aliases are handled.
CST tokens now always include an offset.
directives.marker was renamed to directives.docStart.
error.pos: [number, number] replaces error.offset.
The COMMENT_SPACE error special case was dropped and now uses MISSING_CHAR.
Node ranges now use the [start, value-end, node-end] structure.
Node.js 10 support was dropped.
Node.js 12 support was dropped.
Pair no longer extends NodeBase and no longer forwards its properties.
The tokens namespace was renamed to CST.
Top-level block scalars are stringified with the header on the marker line.
Creating a mapping from a JS Object now drops undefined values.
The yaml/parse-cst endpoint was dropped.
All of yaml/types and some of yaml/util were merged into yaml.
YAML.defaultOptions was removed.
Security 1
yaml is vulnerable to Stack Overflow via deeply nested YAML collections
Deprecations 1
A warning is now emitted for aliases and anchors ending with a colon.
New APIs and options 17
Adds the trailingComma option for multiline flow formatting.
A createNode option named aliasDuplicateObjects was added.
The asBigInt option is supported for sexagesimal integer values.
clone() methods were added to Document, Directives, Schema, and all Nodes.
A compatibility checker was added.
Tags and types required by custom composers are exposed.
A custom schema id is allowed when customTags is defined.
The defaultKeyType option provides finer control of scalar output.
directives.docEnd was added for the ... marker.
The keepSoureToken parse option adds srcToken values to Nodes.
Logging control was refactored and the logLevel option was added.
Support for Non-YAML Schemas was added.
Single and block quotes can now be disabled completely.
Key uniqueness is checked, with uniqueKeys added as an option.
visit(node, visitor) was added to yaml.
The version: 'next' option enables experimental YAML spec features that may change or be removed in minor releases.
YAML.visitAsync() was added.
Behavior and default changes 3
Setting maxAliasCount to 0 disables alias resolution.
The Lexer, Parser, and Composer were turned into generators.
The << merge key now supports immediate map values as well as alias values.
Tooling 1
CST tools were added.
Fixes and other changes 13
Avoids calling Array.prototype.push.apply() with a large source array.
Avoids recursive lexer calls that may exhaust the call stack.
Invalid unicode escapes are now handled.
minFractionDigits is applied only to decimal strings.
Catches stack overflows during node composition.
Empty map values are no longer serialized with double newlines.
Serialization preserves -0 as -0.
The TypeScript type now indicates that doc.directives is optional.
JSON compatibility was improved.
Known tags are now resolved in the core schema.
Using set() in mappings and sequences retains existing nodes.
set() and setIn() create intermediate nodes when used on a document with empty contents.
The tag resolve() API was refactored.