npm / parse5
parse5
What changed in parse5 4 to 8, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-23.
13 breaking7 new APIs and options2 performance5 behavior and defaults1 tooling3 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initparse5 82 changes
Breaking changes 1
parse5 is now ESM-only; applications using CommonJS must adapt their imports.
Performance 1
Uses String.fromCharCode for BMP characters in the tokenizer, a performance optimization.
parse5 715 changes
Breaking changes 5
All parse5 packages are now ECMAScript Modules; dual packages are provided for parse5 and parse5-htmlparser2-tree-adapter.
Parsing results might differ in edge cases as parse5 catches up with the HTML spec.
The adapter now uses domhandler’s node interface, and the format of tree nodes has changed slightly.
The package was removed; use the serialize function exported by parse5.
The rewriting stream no longer escapes text in special tags.
New APIs and options 4
Support for fragments was added to the parser stream.
Added the scriptingEnabled option.
Added serializeOuter, like .outerHTML.
Hooks for stack events were added to the tree adapter interface.
Performance 1
Version 7.0.0 is reported as 45% faster with default options and 167% faster with location information enabled in the bench/perf benchmark on an M1 Mac.
Behavior and default changes 1
The rewriting stream now splits very long text sections.
Tooling 1
parse5 now ships its own types, so remove @types/parse5*.
Fixes and other changes 3
Fixed parsing of << in comments, which was wrongly parsed as <!.
Fixed the position of endTag for mixed-case foreign elements.
Fixed the end position of html and body.
parse5 61 changes
Breaking changes 1
The Tree adapter interface adds this method, enabling usage of custom location info formats; the change is breaking.
parse5 58 changes
Breaking changes 5
Functionality is shipped in separate packages; the parse5 package contains only basic functionality.
SAXParser now passes token objects to event handlers instead of separate arguments.
The location info property name used by currently implemented tree adapters changes from __location to sourceCodeLocation.
The location info property line is renamed to startLine.
parse5 no longer ships TypeScript definitions; existing definitions have moved to DefinitelyTyped.
New APIs and options 3
Adds the endLine location info property.
Adds an HTML rewriting stream package.
Tree adapters should implement this method to control the source code location property.
parse5 45 changes
Breaking changes 1
TypeScript definitions are disabled by default; developers must enable them to use the definitions.
Behavior and default changes 4
This Node.js-specific API is now lazily loaded, enabling bundling of basic functionality for other platforms.
This Node.js-specific API is now lazily loaded, enabling bundling of basic functionality for other platforms.
This Node.js-specific API is now lazily loaded, enabling bundling of basic functionality for other platforms.
This Node.js-specific API is now lazily loaded, enabling bundling of basic functionality for other platforms.