Parsec and Lexbor
Lexbor is the parser I measured Parsec against from the first day. It's good, it's mature, and on some things it's still ahead. Here's where each one stands.
Where Lexbor is ahead
- Years in production. Lexbor has been released since 2018. It's inside PHP 8.4's
Dom\HTMLDocument, selectolax and nokolexbor, and by its own account it's been run against 200 million pages under AddressSanitizer. Parsec's first release was in November 2026. - A bigger DOM. Lexbor can set an element's text, clone and import nodes, look them up by id, class or attribute, and call you back on changes. Parsec's tree has none of those yet: you find nodes with selectors or XPath and edit them directly.
- Some pages, some workloads. Across 1,731 production pages, Lexbor parsed 13 faster than Parsec, nearly all of them small. Its decoders, on their own, beat Parsec's on dense GBK text.
- Packaging. You can install Lexbor from vcpkg, Homebrew and Debian today. Parsec is on crates.io, PyPI and npm, with C packages on GitHub.
What each one has
Lexbor's column is its source at commit 145872a, from 26 October 2026, and Parsec's is the release on crates.io. The module-by-module comparison links every Lexbor claim to the line it comes from; if one's out of date, tell me and I'll fix it.
| What | Lexbor | Parsec |
|---|---|---|
| Parses HTML by the WHATWG standard, whole, in fragments or in chunks | Yes | Yes |
| Streams bytes, sniffing the encoding as they arrive | No: it takes the whole page | Yes, the same document for any split |
| Parse errors | With spec ids, as pointers into the input | With the spec’s names, byte offset, line and column |
| A source position on every node and attribute | No | Yes |
| Limits for hostile input | None | A time budget, a size cap and a depth limit |
| CSS selectors | Level 4, with some pseudo-classes that parse and never match | Level 4, matched as a browser would on a static page |
| XPath | No | XPath 1.0 |
| URLs | Yes, no web-platform-tests count published | Yes, every web-platform-tests case passes |
| Typed CSS values | 105 properties | All 822 in the specs |
| Cascade and computed values | Styles attached; no media queries or computed values | Yes, with media queries against an environment you give |
| DOM: set text, clone, import, look up by id, mutation callbacks | Yes | Not yet |
| Python | Through selectolax, maintained by others | Its own package, with selectolax’s API, XPath and positions |
| Packaged | vcpkg, Homebrew, Debian and more | crates.io, PyPI and npm, and C packages on each release |
Two things Parsec does that the table can't show well: its documents can be shared between threads, which Lexbor's can't, and a node id never dangles after its node is removed, where Lexbor hands out raw pointers. Both are true of the code today, but no test checks them yet, so I'm not counting them as finished.
Speed and memory
Lexbor 3.0.1, built with its own Release flags, against Parsec in the same process on the same input, on an Apple M2 Max (12 cores, 32 GB), macOS 26.7:
- Thirteen real pages: 370 MB/s against 242, 1.53 times as fast, with less memory on every page.
- 1,731 production pages as a crawler fetched them: 933 MB/s against 523.
- 32 selectors over the thirteen pages: 226 ms against 728.
- 80,000 unclosed
<div>s: Parsec at 131 MB/s, Lexbor at 5.2 s a parse, because its work there grows with the square of the depth.
Those are my runs, not anyone else's. Benchmarks has every table and How it's measured has the method and the commands, so you can check them.
Moving from Lexbor or selectolax
If you use Lexbor through selectolax, Parsec's Python package keeps selectolax's API, so the calls you already make keep their names. The docs' Moving from Lexbor page maps the C API call by call.