htmlparser2 is a high-performance, event-driven HTML/XML parser for JavaScript and TypeScript environments. It is currently at stable version 12.0.0 and maintains an active release cadence with frequent updates, often aligning with WHATWG specifications. The library prioritizes speed and efficiency, making it suitable for tasks like web scraping, content transformation, and processing RSS/Atom feeds. While fast and forgiving, it takes some shortcuts compared to strictly spec-compliant parsers like `parse5`, which might lead to different parsing results for highly malformed HTML. It integrates with an ecosystem of related packages like `domhandler` for DOM construction and `css-select` for querying.
No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Since v11.0.0, htmlparser2 is an ESM-only module. CommonJS `require()` is no longer supported.
A convenience function for parsing a document and returning a DOM structure using `domhandler`.
Introduced in v11.0.0, this enables direct piping from Web Streams API responses.
This quickstart demonstrates the event-driven parsing capabilities of htmlparser2 by creating a `Parser` instance and feeding it HTML content. It logs opening tags, text content, and closing tags, illustrating the callback interface.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.
No traffic data recorded yet.