# htmlparser2: 7.3 out of 10

A strong pick. 4th of 10 in [Web scraping and HTML parsing](https://elestia.ai/opensource/scraping/index.md).

htmlparser2 is a fast, forgiving, streaming HTML/XML parser that sits under Cheerio, sanitize-html and many other tools. It is a strong low-level pick when you need speed or streaming, but most scraping code is easier to write with Cheerio on top of it, and parse5 or jsdom fit better when you need a browser-exact tree.

**Best for:** Developers who need a very fast, streaming or callback-based HTML/XML parser, or who build their own tools on a light DOM.

## Scores

- **Overall: 7.3** (likely 6.3 to 8.3)
  - Claude Opus 5.5 (7.0): It is a fast, well-maintained and safe parser that much of the ecosystem trusts, and it is the best pick when you need low-level or streaming HTML/XML parsing. For typical scraping, Cheerio (built on it) is easier to use, and jsdom or parse5-based tools fit better when you need a spec-exact DOM. Its reliance on one maintainer and the recent breaking majors keep it from scoring higher.
  - GPT-6.2 Sol (7.6): htmlparser2 is a strong pick for a new project that needs fast streaming parses or direct access to parser events. Cheerio is a better default for fetching static pages and extracting fields with selectors, and Puppeteer fits pages that need to run JavaScript. The latest version still has browser-parsing differences, and the March release gap and mixed adoption signals temper the recommendation.
- **Needed by many: 4.9** (likely 3.8 to 6.0)
  - Claude Opus 5.5 (5.0): Many projects need to read HTML, but most developers reach for Cheerio, jsdom or a browser tool rather than a raw parser. htmlparser2 serves the smaller group that needs low-level, fast or streaming parsing. It runs in Node and in browsers and handles both HTML and XML, which widens it somewhat.
  - GPT-6.2 Sol (4.8): Scrapers, feed readers, and content processors all need to parse markup, and htmlparser2 works with strings and streams. Its low-level API mainly serves teams that already have the markup and want control over parsing. The feature boundaries are clear, but the evidence gives little sense of how many JavaScript teams need that level of control.
- **Helps a lot: 7.5** (likely 6.5 to 8.5)
  - Claude Opus 5.5 (7.0): It is very fast and forgiving, and it offers a streaming callback API, an optional DOM and XML mode, with built-in types. v12 brought tokenizing much closer to WHATWG. It is still not a full spec tree builder, and it needs helper packages or Cheerio for queries, so for many jobs it is a building block rather than a complete tool.
  - GPT-6.2 Sol (8.0): Version 12 offers typed callbacks and DOM building, and improves how it handles malformed markup. In a 12-page benchmark, it built trees about three times as fast as parse5 on Node and retained much less memory, though node-html-parser finished sooner. Browser-style tree construction remains a limitation, and text callbacks can arrive in pieces. The speed evidence depends on the workload, and the examples and types are easier to assess than the correctness of agent-generated code.
- **Holds up over time: 7.3** (likely 6.2 to 8.4)
  - Claude Opus 5.5 (7.5): The project is 15 years old and still active: 184 commits and 3 releases in the last year, only 4 open issues, and a fresh push. Releases depend mostly on one maintainer, and v11 (ESM only) and v12 (parsing changes) each broke some code. Cheerio and much of the ecosystem depend on it, which strongly pushes it to keep going.
  - GPT-6.2 Sol (7.0): The repository recorded 184 commits and three releases over the past year, with work continuing after the March release. The ESM switch and changes to parsing behavior caused downstream upgrade work. Recent release activity centers on one visible maintainer, and the sponsorship link leaves funding and backup publishing access unclear. The small issue backlog gives limited evidence about response times.
- **Used widely: 6.8** (likely 5.6 to 8.0)
  - Claude Opus 5.5 (7.0): Downloads are huge, about 565M in 4 weeks, and ecosyste.ms counts 2.7M dependent repositories, but most of this comes through Cheerio, sanitize-html, html-react-parser and similar tools. Its ratio of about 3.1 is below the 4.1 median, so its share is slipping slightly. About 2,500 npm packages depend on it directly, which points to many thousands of direct choices.
  - GPT-6.2 Sol (6.6): Four-week downloads rose from 182 million to 565 million, or 3.11 times the prior year, below the catalog median of 4.1 and jsdom's 4.20. The 2.7 million indexed repositories lead this peer set, and 2,492 indexed npm packages show broad use by other libraries. Tools such as Cheerio bring it into projects automatically, and older majors still account for much of weekly npm traffic. The direct share remains hard to estimate, and one Bluesky post offers little evidence of current adoption.
- **Vouched for: 7.5** (likely 6.4 to 8.5)
  - Claude Opus 5.5 (7.0): Widely used tools build on it, including Cheerio, sanitize-html, html-react-parser and eslint-plugin-html, and it is in the dependency trees of large production codebases. An independent benchmark confirms its speed. There is little survey or community discussion of it as a direct choice.
  - GPT-6.2 Sol (7.9): Cheerio uses htmlparser2 for XML and for all parsing in its slim build. PostHTML's parser and sanitize-html both moved to version 12, and an external benchmark measured favorable memory use. These are concrete signs of trust in the parser, though the benchmark covers one corpus and there is little direct evidence of satisfaction among teams that install it themselves.
- **Safe: 8.1** (likely 7.0 to 8.9)
  - Claude Opus 5.5 (8.5): It has no advisories ever recorded, an MIT licence, and only four dependencies, all from the same maintainer (domhandler, domutils, domelementtype, entities). Its Scorecard is 7.3, with weak token permissions, no fuzzing and partly pinned dependencies. Publishing depends mostly on one account.
  - GPT-6.2 Sol (7.6): The MIT license, four direct dependencies, and zero recorded advisories for the package are positives. Version 12 corrected parser behavior that contributed to downstream sanitization bugs. OpenSSF scores code review and the security policy well, with zero scores for token permissions and fuzzing and partial credit for dependency pinning. Limited visibility into release signing and publishing access keeps the range wide.

## Good

- In independent real-world benchmarks it is among the fastest HTML parsers in Node, about four times faster than parse5.
- You can use it as a streaming SAX-style parser or build a light DOM with domhandler, and it handles both HTML and XML.
- It has a small dependency tree of four packages from the same maintainer, no known advisories and built-in TypeScript types.
- It is still actively maintained: v12 brought tokenizing much closer to the WHATWG spec.

## Bad

- It only parses. It does not fetch pages or run JavaScript, and it has no selectors unless you add css-select/domutils or use Cheerio.
- The output tree is still not fully spec-compliant. The maintainer points users to parse5 when the tree must match a browser's.
- Recent majors broke code: v11 dropped CommonJS and requires Node 20.19 or newer, and v12 changed how raw-text tags and entities are parsed.
- Releases depend mostly on one maintainer, Felix Böhm (fb55).

## The numbers

- Downloads, 4 weeks: 565M
- In a year: ×3.1
- GitHub stars: 4.8k
- Commits, 12 months: 184
- Last npm release: Mar 2026
- Advisories, 24 months: 0
- Licence: MIT
- GitHub: https://github.com/fb55/htmlparser2
- npm: https://www.npmjs.com/package/htmlparser2

Scores run from 0 to 10 and are the mean of the scores of AI reviewers (Claude Opus 5.5, GPT-6.2 Sol), made on 22 November 2026 from GitHub, npm, OSV, OpenSSF Scorecard, ecosyste.ms, Hacker News and Bluesky data and a web search. The ecosyste.ms count of repositories that use a project is far too low for projects that grew in the last few years, and some reviews quote it. Overall is the reviewers' own judgement for a new project today, not an average of the parts. An AI wrote them and can be wrong.
