Skip to content
Researched developer tool comparisonsPrices dated · vendor sources linked · no star ratings
Search

Stage 01 · Write · Researched comparison

Best Python HTML Parsers in 2026

Beautiful Soup is the first pick for most developers. It handles messy markup, offers several parser backends, and its API is easy to learn. Choose lxml when speed and XPath support matter, and html5lib when you need strict HTML5 parsing that matches browser behavior. All three are open source and free to use.

By
Published 27 Nov 2026 · 6 tools compared

We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.

Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.

Key takeaways

  • Beautiful Soup is the most forgiving option and works with multiple parser backends, but it is slower than lxml on large documents.
  • lxml is fast and supports XPath, but it needs compiled C libraries and is less tolerant of badly broken HTML.
  • html5lib follows the HTML5 parsing spec closely, which helps with malformed pages, at the cost of speed.
  • All parsers listed here are free and open source, and they run locally, so page data never leaves your machine.

Who each pick is for

Comparison

The 6 tools at a glance
ToolBest forStandout featureListed starting priceFree plan or trial
1Beautiful SoupBeginners and messy HTMLTolerant of broken markupFree (open source)Free plan
2lxmlSpeed and XPath queriesFast parsing and serializationFree (open source)Free plan
3html5libStrict HTML5 spec complianceFollows the HTML5 parsing algorithmFree (open source)Free plan
4selectolaxHigh-speed CSS selector extractionVery fast parsing via LexborFree (open source)Free plan
5parselScrapy-style selector extractionSupports CSS and XPath selectorsFree (open source)Free plan
6PyQueryjQuery-style DOM queriesFamiliar jQuery syntaxFree (open source)Free plan

How we picked

We compared libraries on fit for HTML parsing and extraction, supported platforms, licence and price, tolerance of malformed markup, speed characteristics as described in project documentation, and main limits such as compiled dependencies or missing XPath. Sources are official project pages, documentation and repositories. Prices and licences can change, so confirm details on the project site before you commit.

The tools, one by one

01

Beautiful Soup

Best for beginners and messy HTML

Visit crummy.com
Beautiful Soup homepage
Beautiful Soup homepage, captured Nov 2026

What it is and where it fits

Beautiful Soup is a Python library for pulling data out of HTML and XML files. It builds a parse tree you can search with tags, attributes and CSS selectors. It can use several backends, including lxml, html5lib and Python's built-in html.parser, so you can trade speed for tolerance. It runs anywhere Python runs and is distributed under the MIT licence.

The main strength is handling malformed pages. When markup is broken, Beautiful Soup usually still produces a usable tree. The cost is speed: on large documents it is slower than lxml. It also lacks native XPath, so you rely on its own search methods or CSS selectors. Skip it if you parse very large volumes and need maximum throughput.

Standout: Tolerant of broken markup

Pricing pointer

Free (open source), as listed by the vendor (Beautiful Soup website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Tolerant of broken markup
  • Works with multiple parser backends

Drawbacks

  • Slower than lxml
  • No native XPath support

Skip it if this limit matters to you: slower than lxml.

Verdict. A sensible pick for beginners and messy HTML.

Alternatives in this guide: lxml, html5lib, selectolax

02

lxml

Best for speed and XPath queries

Visit lxml.de
lxml homepage
lxml homepage, captured Nov 2026

What it is and where it fits

lxml is a Python binding for the libxml2 and libxslt C libraries. It parses HTML and XML quickly and supports XPath, XSLT and CSS selectors. It runs on Linux, macOS and Windows, though installation can require system libraries or prebuilt wheels. It is distributed under the BSD licence.

For large documents or high-volume scraping, lxml is usually the fastest choice among pure Python-facing parsers. The trade-off is tolerance: its HTML parser is stricter than html5lib and may drop or rearrange badly broken markup. It also adds a compiled dependency, which complicates deployment on some platforms. Choose it when speed and XPath matter more than forgiving parsing.

Standout: Fast parsing and serialization

Pricing pointer

Free (open source), as listed by the vendor (lxml website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Fast parsing and serialization
  • Full XPath and CSS selector support

Drawbacks

  • Requires compiled C libraries
  • Less forgiving of broken HTML

Skip it if this limit matters to you: requires compiled C libraries.

Verdict. A sensible pick for speed and XPath queries.

Alternatives in this guide: Beautiful Soup, html5lib, selectolax

03

html5lib

Best for strict HTML5 spec compliance

Visit github.com
html5lib homepage
html5lib homepage, captured Nov 2026

What it is and where it fits

html5lib is a pure Python parser that implements the WHATWG HTML5 parsing algorithm. It produces a tree that matches how browsers interpret the same markup, which helps when pages are malformed. It runs anywhere Python runs and is distributed under the MIT licence. It is also available as a backend for Beautiful Soup.

The main reason to pick html5lib is predictability. If you need parsing that matches browser behavior, it is the closest option. The cost is speed: it is slower than lxml and often slower than Beautiful Soup with the built-in parser. Use it when correctness on broken pages matters more than throughput, and pair it with Beautiful Soup if you want a friendlier search API.

Standout: Follows the HTML5 parsing algorithm

Pricing pointer

Free (open source), as listed by the vendor (html5lib website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Follows the HTML5 parsing algorithm
  • Handles malformed markup predictably

Drawbacks

  • Slower than lxml
  • Larger dependency footprint

Skip it if this limit matters to you: slower than lxml.

Verdict. A sensible pick for strict HTML5 spec compliance.

Alternatives in this guide: Beautiful Soup, lxml, selectolax

04

selectolax

Best for high-speed CSS selector extraction

Visit github.com
selectolax homepage
selectolax homepage, captured Nov 2026

What it is and where it fits

selectolax is a Python library built on the Lexbor HTML engine. It focuses on fast parsing and CSS selector queries, and it is often faster than lxml for selector-based extraction. It runs on Linux, macOS and Windows via prebuilt wheels and is distributed under the MIT licence.

The API is small: parse a document, then query with CSS selectors. That makes it easy to learn but less flexible than lxml for XPath or XSLT work. The project has a smaller community than Beautiful Soup or lxml, so fewer tutorials and answers exist. Choose it for high-volume extraction where CSS selectors cover your needs and speed is the priority.

Standout: Very fast parsing via Lexbor

Pricing pointer

Free (open source), as listed by the vendor (selectolax website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Very fast parsing via Lexbor
  • Simple CSS selector API

Drawbacks

  • Smaller community than older libraries
  • Fewer features than lxml

Skip it if this limit matters to you: smaller community than older libraries.

Verdict. A sensible pick for high-speed CSS selector extraction.

Alternatives in this guide: Beautiful Soup, lxml, html5lib

05

parsel

Best for scrapy-style selector extraction

Visit github.com
parsel homepage
parsel homepage, captured Nov 2026

What it is and where it fits

parsel is the selector library used by the Scrapy web scraping framework. It wraps lxml and exposes a simple API for CSS and XPath queries, plus helpers for extracting text and attributes. It runs wherever lxml runs and is distributed under the BSD licence.

If you already use Scrapy, parsel lets you reuse the same selector code outside spiders. It is also a reasonable standalone choice when you want both CSS and XPath with a compact API. Because it depends on lxml, it inherits lxml's speed and its stricter handling of broken HTML. Skip it if you want a parser with no compiled dependencies.

Standout: Supports CSS and XPath selectors

Pricing pointer

Free (open source), as listed by the vendor (parsel website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Supports CSS and XPath selectors
  • Same API used inside Scrapy

Drawbacks

  • Built on lxml, so inherits its limits
  • Less known outside scraping

Skip it if this limit matters to you: built on lxml, so inherits its limits.

Verdict. A sensible pick for scrapy-style selector extraction.

Alternatives in this guide: Beautiful Soup, lxml, html5lib

06

PyQuery

Best for jQuery-style DOM queries

Visit github.com
PyQuery homepage
PyQuery homepage, captured Nov 2026

What it is and where it fits

PyQuery lets you query HTML with jQuery-style selectors and methods. It is built on lxml, so it parses quickly, and it runs wherever lxml runs. It is distributed under the BSD licence. The API will feel familiar to developers who have written front-end jQuery code.

The main use case is teams that already know jQuery syntax and want the same style in Python. It supports CSS selectors and common DOM manipulation methods. The trade-offs are the lxml dependency and an API that differs from Beautiful Soup or lxml, which can confuse mixed codebases. Choose it when jQuery-style queries are a better fit for your team.

Standout: Familiar jQuery syntax

Pricing pointer

Free (open source), as listed by the vendor (PyQuery website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Familiar jQuery syntax
  • Built on lxml for speed

Drawbacks

  • Depends on lxml
  • API differs from standard Python libraries

Skip it if this limit matters to you: depends on lxml.

Verdict. A sensible pick for jQuery-style DOM queries.

Alternatives in this guide: Beautiful Soup, lxml, html5lib

Who should use what

If you are new to scraping or pages are messy, start with Beautiful Soup. If you parse large volumes and need XPath, use lxml. If browser-accurate parsing of broken markup matters, choose html5lib. If you need maximum speed with CSS selectors, try selectolax. Teams already using Scrapy should consider parsel, and developers who prefer jQuery syntax should look at PyQuery.

Questions to settle before you buy

What to check before you buy

  • Confirm the library handles the malformed markup common on your target sites.
  • Check whether you need XPath, CSS selectors or both.
  • Verify installation on your deployment platform, especially for compiled dependencies like lxml.
  • Review the licence if you ship the library in a commercial product.
  • Test parsing speed on a sample of your real documents before committing.

FAQ

Which Python HTML parser is fastest?

lxml and selectolax are generally the fastest options described in their documentation. lxml uses compiled C libraries, and selectolax uses the Lexbor engine. Beautiful Soup and html5lib are slower but more tolerant or more spec-compliant. Measure on your own documents, since results depend on markup and query style.

Can Beautiful Soup use lxml or html5lib?

Yes. Beautiful Soup accepts a parser argument and can use lxml, html5lib or Python's built-in html.parser as backends. This lets you combine Beautiful Soup's search API with lxml's speed or html5lib's tolerance. You must install the backend library separately.

Do these parsers send my data anywhere?

No. These are local Python libraries. They parse content you pass to them and do not send it to a server. If you use an online HTML viewer or formatter instead, avoid pasting secrets, tokens or production data into third-party web pages, and prefer tools that run locally in the browser or offline.

Do I need XPath or are CSS selectors enough?

CSS selectors cover most extraction tasks and are simpler to write. XPath is more expressive for complex queries, such as selecting by text content or navigating axes. lxml, parsel and PyQuery support XPath. Beautiful Soup does not support XPath natively.

Are these libraries free for commercial use?

All libraries listed here are open source and free to use. Check each licence: Beautiful Soup, html5lib and selectolax use the MIT licence, while lxml, parsel and PyQuery use the BSD licence. Both licences generally permit commercial use with attribution requirements.

Sources we checked

Method: how we score · editorial policy.

  1. Beautiful Soup (official site)
  2. lxml (official site)
  3. html5lib (official site)
  4. selectolax (official site)
  5. parsel (official site)
  6. PyQuery (official site)

Change log. First published 27 Nov 2026.