lexbor: a zero-dependency C99 library for HTML parsing, CSS processing and URL handling
Lexbor is development of an open source HTML Renderer library. https://lexbor.com
At a glance
- What is it?
- lexbor is a modular C99 library covering HTML parsing, CSS, URL, Encoding, Unicode and Punycode, all written without external dependencies. PHP uses it for its DOM, HTML and URL extensions, and the Layout and Fonts modules needed for full rendering remain incomplete.
- Who is it for?
- lexbor is the right choice when you need standards-compliant HTML and CSS parsing in a C project with no dependencies and when PHP-style language bindings are an option for the wrapping layer. Projects that need a complete rendering pipeline should look elsewhere: the Layout and Fonts modules are listed as in progress and lexbor makes no rendering promises yet.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 13 days ago.
- What is it written in?
- Mainly C, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 6, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Parsing HTML, CSS and URLs in C with no external dependencies
lexbor is a C99 library that covers the browser-side parsing stack: HTML documents, CSS stylesheets, URL normalization, text encoding conversion, and Unicode handling. All modules are written in pure C99 with zero runtime dependencies, which means embedding lexbor in a project requires no dependency management and no additional toolchain setup beyond a C99 compiler and CMake.
PHP adopted lexbor for its DOM and HTML extension starting in PHP 8.4, and for its URL extension in PHP 8.5. SerpApi uses it for HTML parsing at scale. Selectolax wraps it for Python, and Nokolexbor wraps it for Ruby. Additional bindings exist for Elixir, Crystal, D, Julia and Erlang, giving access from 8 different language ecosystems.
The project description is explicit about scope: lexbor is still in development as a full browser engine, but the 7 production-ready modules are independently stable and used in production today.
7 ready modules and 2 still in progress: what lexbor can and cannot do today
Seven modules are production-ready: DOM (tree manipulation), HTML (full parser), CSS (parsing, CSSOM, selectors), URL (parsing), Encoding (40+ encodings), Unicode (normalization, IDNA) and Punycode (IDN encode/decode). Two more, Layout and Fonts, are listed as in progress with no description of their current state.
Each module is independent. A project that needs only CSS selector matching can include the CSS and Selectors modules without the HTML parser. One that needs URL normalization can pull in only the URL module. This modularity keeps compiled output small for constrained environments.
The Encoding module supports 40+ encodings for both single and buffering encode/decode. Unicode covers 4 normalization forms (NFD, NFC, NFKD, NFKC) plus IDNA Processing, ToASCII and ToUnicode as specified in Unicode Technical Standard #46.
Installing via Homebrew, vcpkg, system packages or CMake from source
macOS users with Homebrew can install lexbor with:
brew install lexborFor MacPorts:
sudo port install lexborOn Windows and other platforms, the vcpkg port installs via:
vcpkg install lexborBuilding from source uses CMake with optional test and example targets:
cmake . -DLEXBOR_BUILD_TESTS=ON -DLEXBOR_BUILD_EXAMPLES=ON
make
make testPre-built binary packages are available for CentOS 6/7/8, Debian 8/9/10/11, several Fedora versions, RHEL 7/8 and multiple Ubuntu versions, all for x86_64 only. For other architectures, the README points to [email protected]. Source builds work on any platform a C99 compiler supports.
An amalgamation build is also available, combining all selected modules into a single header and source file. This eliminates file management for projects that embed lexbor directly rather than installing it as a system library.
How the HTML module parses: 2 modes, fragment support and 200 million-page testing
lexbor's HTML module offers 2 parsing approaches. The Document mode parses a complete HTML document and builds the full tree. The Parser mode uses the underlying parser directly and gives more control over the process. Fragment parsing, which covers the innerHTML case, is also supported.
Parsing by chunks is available, which matters for streaming use cases where the full document is not available at once. Encoding detection from the byte stream is built in, so lexbor can determine the document's character encoding without requiring the caller to specify it upfront.
For correctness testing, the module was run against 200 million+ HTML pages using AddressSanitizer (ASAN). It passes all tree construction tests from the HTML5 specification. This combination of a large real-world corpus and specification test suite is one of the more concrete testing descriptions in the README.
The CSS module: Selectors, CSSOM and conformance with the CSS Syntax specification
CSS parsing covers 3 areas: the Selectors module for querying DOM trees with CSS selector syntax, the StyleSheet Tree (CSSOM) for structured access to parsed stylesheets, and the base CSS parser conforming to the CSS Syntax specification. Inline styles in tag attributes and styles in `<style>` tags are both handled by the HTML module as part of document parsing.
The Selectors module is independent of the HTML module, so it can be used to query any DOM tree that lexbor's DOM module manages, regardless of how that tree was built. This separation allows CSS-selector-based querying to be added to workflows that build DOM trees programmatically rather than by parsing HTML.
Conformance targets include the CSS Syntax Level 3 draft specification. Full CSS property value parsing is not mentioned in the README, which means computed styles and cascade resolution are out of scope for the current CSS module.
What lexbor cannot do yet and when a single-purpose parser is a better fit
Layout and Fonts remain incomplete. Without these 2 modules, lexbor cannot perform visual rendering: it parses and processes the content of a page but has no mechanism to determine how elements appear on screen. A project that only needs to parse or scrape HTML does not need rendering, but a project building a browser or document viewer does, and lexbor does not meet that requirement today.
For applications that only parse HTML and have no need for CSS selectors, URL normalization or Unicode processing, a narrower single-purpose HTML5 parser carries less integration surface than lexbor's full module set. lexbor's modular design does allow individual modules to be built in isolation, but the default Homebrew and system packages install the full library. Projects needing a thinner integration point would build from source with only the modules they need.
Among the top-level entries sit a benchmarks/ directory and a wasm/ directory, both present without further description in any README section.
Language bindings: PHP native integration and wrappers for Python, Ruby and 5 more
PHP integrates lexbor natively: the DOM and HTML extensions use lexbor since PHP 8.4, and the URL extension uses it since PHP 8.5. These are first-party PHP extensions, not third-party wrappers, which means PHP 8.4+ applications using DOM or HTML parsing already depend on lexbor without any additional installation.
For Python, Selectolax provides a high-level scraping API on top of lexbor. For Ruby, Nokolexbor is described as a high-performance Nokogiri alternative. Nordstjernen is a web browser written entirely in C that uses lexbor.
The README lists further bindings for Elixir, Crystal, D, Julia and Erlang under an external bindings section. These are community-maintained rather than official lexbor projects. For C callers, lexbor's own C API is the direct interface; for everyone else, one of these wrappers is the expected path.
Editorial conclusion
lexbor is the right choice when you need standards-compliant HTML and CSS parsing in a C project with no dependencies and when PHP-style language bindings are an option for the wrapping layer. Projects that need a complete rendering pipeline should look elsewhere: the Layout and Fonts modules are listed as in progress and lexbor makes no rendering promises yet. Install via Homebrew, vcpkg or CMake; the binary packages cover x86_64 only. v3.0.0, published on 2026-03-31, is the current version. lexbor carries an Apache-2.0 licence.
Frequently asked questions
What is lexbor?
lexbor is a zero-dependency C99 library for HTML parsing, CSS processing, URL handling, Unicode normalization and Punycode encoding. It is used by PHP for its DOM, HTML and URL extensions, and by Python and Ruby through wrapper libraries.
How do I install lexbor?
On macOS, install via Homebrew with `brew install lexbor` or MacPorts with `sudo port install lexbor`. On Windows, use `vcpkg install lexbor`. Linux binary packages are available for CentOS, Debian, Fedora, RHEL and Ubuntu (x86_64 only). Building from source uses CMake.
Is lexbor production-ready?
lexbor is still in development as a full browser engine, but the existing modules are production-ready. PHP has used the DOM and HTML modules since PHP 8.4 and the URL module since PHP 8.5. The Layout and Fonts modules are not yet ready.
Can lexbor be used without all modules?
lexbor uses a modular architecture where each module can be used independently. A project needing only CSS selector matching can include just the CSS and Selectors modules; one needing only URL parsing can use only the URL module. Building from source lets you select which modules to compile.
Does lexbor support non-English web pages and character encodings?
lexbor's Encoding module supports 40+ encodings with both single and buffered encode/decode. The Unicode module covers NFD, NFC, NFKD and NFKC normalization forms, IDNA Processing, ToASCII and ToUnicode. The HTML parser also detects encoding from the byte stream.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/lexbor-lexbor)