npm / htmlparser2
htmlparser2
What changed in htmlparser2 10 to 12, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-28.
17 breaking1 new APIs and options8 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli inithtmlparser2 1217 changes
Breaking changes 11
In HTML mode, processing instructions and non-DOCTYPE declarations emit bogus comments instead of being silently dropped.
CDATA sections inside foreign content are treated as text.
An empty end tag is silently ignored rather than emitted as text.
An h1–h6 element implicitly closes other headings.
image is rewritten to img outside foreign content.
A nested form is ignored when another form is already open.
iframe, noembed, noframes, and plaintext content is no longer parsed as HTML.
Self-closing script and style tags enter raw-text state when recognizeSelfClosing is not enabled; the slash is ignored per spec.
Special-tag detection is disabled inside foreign content.
Tag names inside svg are adjusted per spec, including foreignObject and clipPath.
textarea now decodes entities, matching title behavior.
Fixes and other changes 6
An a element closes a previously open a element.
DOCTYPE declarations without a space after DOCTYPE are recognized.
Unclosed comments, DOCTYPEs, processing instructions, and CDATA sections emit the correct token type at EOF.
Stray svg and math end tags no longer corrupt parser context tracking.
Several comment forms that were previously invalid are now parsed as valid comments per spec.
reset() now clears attribute state, preventing data from leaking across parseComplete() calls.
htmlparser2 118 changes
Breaking changes 5
The module is ESM only; CommonJS require() is no longer supported in legacy environments, so use import instead.
The minimum supported Node.js version is now 20.19.0.
The deprecated parseDOM function was removed.
In xmlMode, <!--> is no longer treated as a complete comment.
XML processing instructions now require the full ?> closing sequence instead of just >.
New APIs and options 1
Added WebWritableStream for the Web Streams API, enabling direct piping from fetch() response bodies into the parser.
Fixes and other changes 2
In HTML mode, comments accept --!> as a closing sequence, and <!--> is recognized as an empty comment.
reset() now clears isSpecial and sequenceIndex state, preventing incorrect parsing after reuse.
htmlparser2 101 changes
Breaking changes 1
Test files are no longer included in the published module, changing the files available to consumers of the package.