parse5
8.1.0 · 1 Nov 2026MIT227.5M / weekRepositoryHomepagenpmAtom feed
61 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 8.x · latest line
8.1.0
1 Nov 2026Expose element creation context to tree adapters
Treat numeric character reference CR as whitespace
parser: Match only HTML elements in the "any other end tag" step
What's Changed
Expose element creation context to tree adapters
Treat numeric character reference CR as whitespace
parser: Match only HTML elements in the "any other end tag" step
Export InsertionMode enum from parse5
Allow flushing buffered character tokens
tokenizer: Append attribute values and character runs as slices of the input
End attribute names when missing whitespace
8.0.1
19 Apr 2026tokenizer: Use String.fromCharCode for BMP characters
Use Uint8Array bitmaps for faster tag ID lookups
Revert "perf: use Uint8Array bitmaps for faster tag ID lookups"
What's Changed
tokenizer: Use String.fromCharCode for BMP characters
Use Uint8Array bitmaps for faster tag ID lookups
Revert "perf: use Uint8Array bitmaps for faster tag ID lookups"
8.0.0
9 Jul 2025Switch to ESM-only
What's Changed
Switch to ESM-only
Bump to 8.0.0
- 7.x
7.3.0
22 Apr 2025Bump dependencies
Fix broken links to documentation
Account for undefined in element stack
What's Changed
Bump dependencies
Upgrade entities
Fix broken links to documentation
Account for undefined in element stack
7.2.1
28 Oct 2024Bump dependencies
Export tree adapter types as namespace to support TS4.x
What's Changed
Bump dependencies
Export tree adapter types as namespace to support TS4.x
7.2.0
12 Oct 2024Bump dependencies
parser: Support search element
parse5: Change parser/tokenizer methods to be protected
What's Changed
Bump dependencies
parser: Support search element
parse5: Change parser/tokenizer methods to be protected
Don't generate sourcemap on build, close #831
Fix
<noframes>parsingUse typedoc config to avoid accidental inheritance
7.1.2
20 Nov 2022Export
ERRasErrorCodesProperly handle CR when peeking
Add CJS build of
parser-stream
This release includes
parse5andparse5-parser-stream.Export
ERRasErrorCodesProperly handle CR when peeking
Add CJS build of
parser-stream
7.1.1
2 Sep 20227.1.0
2 Sep 2022parse5: Use string types for node names
parser: Have
</button>close<p>Added coverage reporting
This release is only for the parse5 module.
What's Changed
parse5: Use string types for node names
parser: Have
</button>close<p>Added coverage reporting
Improved code coverage
7.0.0
20 Apr 2022- breaking
The
parse5-serializer-streampackage was removed #481
Welcome to parse5@7.0.0! ✨ This is a huge release with many changes, features and fixes.
From an organisational perspective, the most important change is that parse5 is now maintained by a team, consisting of James (@43081j), Titus (@wooorm) and me (@fb55). We come from three projects that rely on parse5 — namely Cheerio, rehype, and Lit.
We need your support to continue the project! If you care about parse5, please support us financially on OpenCollective.
Headlining features of this release are ES Modules, TypeScript, and performance improvements: 7.0.0 is 45% faster than 6.0.1 with default options, and 167% faster with location information enabled (for the
bench/perfbenchmark, on an M1 Mac). Version 7.0.0 is a revamp of every part of the library. There are too many changes to list them all here, so here is a high-level overview:Breaking: ESM
All of parse5’s packages are now ECMAScript Modules. We are providing dual packages for
parse5andparse5-htmlparser2-tree-adapterfor now (see #418 and #496).To migrate, please read this Gist on how to update. Note that private internals are no longer available; instead, everything that you need should be imported from the main package.
Implemented by @43081j in #351
Breaking: TypeScript
The codebase has been ported to TypeScript. This helped uncover a number of subtle logic bugs, such as dc4e269, b4b5d4a, or a0aff95. TypeScript also helps us refactor with confidence and a lot of the changes in this release would have been much harder to do without it.
To migrate, please remove
@types/parse5*as we now ship our own types.Potentially breaking changes
- breaking
parse5 was caught up with the HTML spec, and parsing results might differ in edge-cases (#442, #451)
- breaking
The
parse5-serializer-streampackage was removed #481To migrate, use the
serializefunction exported byparse5.
- breaking
The rewriting stream now splits very long text sections (#434) and doesn’t escape text in special tags anymore (#434). If you worked around these issues before, you might have to update your code.
- breaking
The htmlparser2 adapter now uses
domhandler’s node interface (#327The format of the tree nodes has changed slightly; eg. some previous properties are now getters and setters, and vice versa.
If you are using deep imports for any parts of the codebase, you will likely encounter some breakages:
Show internal changes
- breaking
The tokenizer now uses the state machine pattern from htmlparser2
5d7a780(#362) - breaking
The token queue was replaced with callbacks (#404, #405, #419)
- breaking
The
OpenElementStacknow uses callbacks #429 - breaking
Mixins were removed (as part of #362)
Location tracking now has a substantially lower overhead #402
- breaking
getNextTokenwas removed #461 - breaking
The parser’s
_bootstrapmethod was removed #384 - breaking
We now drop chunks from the tokenizer right after they are emitted #432
- breaking
The serializer is no longer a class; instead, different serializer functions call on each other #383
- breaking
parse5 now uses the
entitiesmodule for encoding and decoding entities, sharing maintenance & optimisation work with projects such as htmlparser2 (2b92054(#362), #486)entitiesadopted a variant of parse5’s approach of decoding entities. As a result, decoding performance is equivalent, while memory consumption is slightly lower.
Other changes
minor add hooks for stack events to tree adapter interface #385
minor add support for fragments in
parse5-parser-stream#487minor add
serializeOuter(like.outerHTML),scriptingEnabledoption #383patch fix parsing of
<<in comments parsed wrongly as<!patch fix position of
endTagfor mixed-case foreign elementspatch fix end position of
html,body
- 6.x
- 5.x
5.1.1
6 Nov 2019Fixed: Serialization of attributes in non-standard namespaces
Fixed: Quirks and limited-quirks mode detection by doctype
5.1.0
13 Aug 2018Fixed: Location info for
textevents inSAXParserandRewritingStreamnow contains
correctendColandendLinecovering all concatenated raw tokens (GH #266).Fixed:
SAXParserandRewritingStreamnow flush last buffered chunk when calling.end()with
no parameters (GH #271).Updated (breaking):
ParserStream,SAXParserandRewritingStreamno longer assume that
each binary chunk is a valid finished UTF-8 chunk, and instead accept only decoded strings (GH #269).
5.0.0
23 May 2018Updated (breaking): source code location now inserted by tree adapter, so tree adapter developers have control over location info property name. Tree adapters should implement setNodeSourceCodeLocation and getNodeSourceCodeLocation methods. Location info property name added by currently implemented tree adapters has been renamed from
__locationtosourceCodeLocation(GH #189).Updated (breaking):
SAXParsernow passes token objects to event handlers instead of separate arguments. See SAXParser documentation for more info.
(GH #247).
Starting from this release
parse5functionality will be shipped in separate packages. Withparse5package contatining only basic functionality. Please, refer to the list of packages for more info.Updated (breaking): source code location now inserted by tree adapter, so tree adapter developers have control over location info property name. Tree adapters should implement setNodeSourceCodeLocation and getNodeSourceCodeLocation methods. Location info property name added by currently implemented tree adapters has been renamed from
__locationtosourceCodeLocation(GH #189).Updated (breaking): Location info
lineandcolproperties have been renamed to startLine and
startCol
respectively.Updated (breaking):
SAXParsernow passes token objects to event handlers instead of separate arguments. See SAXParser documentation for more info.
(GH #247).Added: scriptingEnabled flag to the
ParserOptionswhich controls how<noscript>tags are handled by the parser. (GH #192).Added: HTML rewriting stream.
(GH #222).Removed (breaking):
parse5no longer ship TypeScript definitions. Existing TypeScript definitions have been moved to DefinitelyTyped repo. Please, track the PR in the DefinitelyTyped repo for the updates.
- 4.x
4.0.0
13 Jan 2018Updated (breaking): TypeScript were disabled by default. See TypeScript definitions section for the details on how to enable them.
Updated: API that depends on Node.js specific (namely
ParserStream,PlainTextConversionStream,SerializerStream,SAXParser) is now lazily loaded. That enables bundling of the basic functionality for other platforms (e.g. for browsers via webpack).
This is a major release that delivers few minor (but breaking) changes to workaround recently appeared issues with TypeScript Node.js typings versioning and usage of parse5 in environments that are distinct from Node.js (see #235 for the details).
Updated (breaking): TypeScript were disabled by default. See TypeScript definitions section for the details on how to enable them.
Updated: API that depends on Node.js specific (namely
ParserStream,PlainTextConversionStream,SerializerStream,SAXParser) is now lazily loaded. That enables bundling of the basic functionality for other platforms (e.g. for browsers via webpack).
- 3.x
3.0.3
5 Nov 2017Fixed: Loosen the dependency version of
@types/nodeFixed: Incorrect AST generated if empty string fed to
ParserStream(GH #195)
3.0.0
5 Dec 2016Added: parse5 now ships with TypeScript definitions from which new documentation website is generated (GH #125).
Added: PlainTextConversionStream (GH #135).
Updated: Significantly reduced initial memory consumption (GH #52).
Added: parse5 now ships with TypeScript definitions from which new documentation website is generated (GH #125).
Added: PlainTextConversionStream (GH #135).
Updated: Significantly reduced initial memory consumption (GH #52).
Updated (breaking): Added support for limited quirks mode.
document.quirksModeproperty was replaced withdocument.modeproperty which can have'no-quirks','quirks'and'limited-quirks'values. Tree adaptersetQuirksModeandisQuirksModemethods were replaced withsetDocumentModeandgetDocumentModemethods (GH #83).Updated (breaking): AST collections (e.g. attributes dictionary) don't have prototype anymore (GH #119).
Updated (breaking): Doctype now always serialized as
<!DOCTYPE html>as per spec (GH #137).Fixed: Incorrect line for
__location.endTagwhen the start tag contains newlines (GH #166)
- 2.x
2.2.2
29 Sep 20162.2.1
1 Sep 2016Fixed: SAXParser HTML integration point handling for adjustable SVG tags.
Fixed: SAXParser now adjust SVG tag names for end tags.
Fixed: Location info line calculation on tokenizer character unconsumption
2.2.0
11 Aug 2016SAXParser
Latest spec changes
Fixed: Element nesting corrections now take namespaces into consideration.
2.0.0
7 Dec 2015- removed
Removed (breaking):
decodeHtmlEntitiesandencodeHtmlEntitiesoptions. (GH #75). Added: ParserStream with the scripting support. (GH #26).
Added: SerializerStream. (GH #26).
Added: ParserStream with the scripting support. (GH #26).
Added: SerializerStream. (GH #26).
Added: Line/column location info. (GH #67).
Update (breaking): Location info properties
startandendwere renamed tostartOffsetandendOffsetrespectively.Update (breaking):
SimpleApiParserwas renamed to SAXParser.Update (breaking): SAXParser is the transform stream now. (GH #26).
Update (breaking): SAXParser handler subscription is done via events now.
Added: SAXParser.stop(). (GH #47).
Add (breaking): parse5.parse() and parse5.parseFragment() methods as replacement for the
Parserclass.Add (breaking): parse5.serialize() method as replacement for the
Serializerclass.Updated: Parsing algorithm was updated with the latest HTML spec changes.
- removed
Removed (breaking):
decodeHtmlEntitiesandencodeHtmlEntitiesoptions. (GH #75). Add (breaking): TreeAdapter.setTemplateContent() and TreeAdapter.getTemplateContent() methods. (GH #78).
Update (breaking):
defaulttree adapter now stores<template>content intemplate.contentproperty instead oftemplate.childNodes[0].
- 1.x
1.5.0
24 Jun 2015Added: Location info for the element start and end tags
1.4.0
24 Feb 2015Added: Parser decodeHtmlEntities option.
Added: SimpleApiParser decodeHtmlEntities option.
Added: Parser locationInfo option.
Added: Parser decodeHtmlEntities option.
Added: SimpleApiParser decodeHtmlEntities option.
Added: Parser locationInfo option.
Added: SimpleApiParser locationInfo option.
1.3.0
24 Dec 2014Added: Serializer
encodeHtmlEntitiesoption.Added:
<template>supportparseFragmentnow uses<template>as defaultcontextElement. This leads to the more "forgiving" parsing manner.
Added: Serializer
encodeHtmlEntitiesoption.
From 1.2.0:
Added:
<template>supportparseFragmentnow uses<template>as defaultcontextElement. This leads to the more "forgiving" parsing manner.TreeSerializerwas renamed toSerializer. However, serializer is accessible asparse5.TreeSerializerfor backward compatibility .
1.2.0
6 Nov 20141.1.6
18 Oct 2014Fixed: apply latest changes to the
htmlparser2tree format (DOM Level1 node emulation).
1.1.3
8 Sep 2014Development files (e.g.
.travis.yml,.editorconfig) are removed from NPM package.
1.1.2
19 Aug 2014Fixed: crash on Linux due to upper-case leading character in module name used in
require().
1.1.1
18 Aug 2014Added: SimpleApiParser.
Fixed: new line serialization in
<pre>.Fixed:
SYSTEM-onlyDOCTYPEserialization.
Added: SimpleApiParser.
Fixed: new line serialization in
<pre>.Fixed:
SYSTEM-onlyDOCTYPEserialization.Fixed: quotes serialization in
DOCTYPEIDs.