skillfed

html5lib

HTML parser based on the WHATWG HTML specification

html5lib Permissive license MIT License Active 1,224 v1.1 released

Install

html5lib on PyPI

pip

pip install html5lib

uv

uv add html5lib

poetry

poetry add html5lib

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*)
Install friction low — pure-Python wheel
Runtime dependencies 2 — six, webencodings
Maintenance actively maintained — 2,243 days since the last release
Last repo commit
First released
Popularity one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13)
Known vulnerabilities none known (OSV.dev, checked 2026-08-13)

Evidence: html5lib-1.1-py2.py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: HTML

About html5lib

from the package's own PyPI description — quoted content, verbatim

html5lib

.. image:: https://travis-ci.org/html5lib/html5lib-python.svg?branch=master :target: https://travis-ci.org/html5lib/html5lib-python

html5lib is a pure-python library for parsing HTML. It is designed to conform to the WHATWG HTML specification, as is implemented by all major web browsers.

Usage

Simple usage follows this pattern:

.. code-block:: python

import html5lib with open("mydocument.html", "rb") as f: document = html5lib.parse(f)

or:

.. code-block:: python

import html5lib document = html5lib.parse("<p>Hello World!")

By default, the document will be an xml.etree element instance. Whenever possible, html5lib chooses the accelerated ElementTree implementation (i.e. xml.etree.cElementTree on Python 2.x).

Two other tree types are supported: xml.dom.minidom and lxml.etree. To use an alternative format, specify the name of a treebuilder:

.. code-block:: python

import html5lib with open("mydocument.html", "rb") as f: lxml_etree_document = html5lib.parse(f, treebuilder="lxml")

When using with urllib2 (Python 2), the charset from HTTP should be pass into html5lib as follows:

.....

Read as markdown · JSON record · Source repository · Homepage

AI interpretation — verify before relying

AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page

html5lib is a pure-Python HTML parser that conforms to the WHATWG HTML specification, parsing HTML documents into tree structures compatible with xml.etree, xml.dom.minidom, or lxml.

Low install friction with just two runtime dependencies (six and webencodings). Repository is active with recent commits and 1224 stars, though the latest release was over 5 years ago (2020-06-22).

MIT License (permissive) allows commercial and private use with minimal restrictions, requiring only license and copyright notice retention.

Usage

import html5lib
document = html5lib.parse("<p>Hello World!")
# or from file:
with open("mydocument.html", "rb") as f:
    document = html5lib.parse(f)

Requires Python 2.7 or Python 3.5+; optional lxml dependency for lxml tree format (not supported on PyPy).

Verdict: html5lib is a stable, actively maintained HTML parser with minimal dependencies and no known vulnerabilities. The long gap since the last release (2020) is offset by recent repository activity. It's suitable for production use where WHATWG-compliant HTML parsing is needed, though users should verify ongoing maintenance aligns with their support expectations.

Needs verification

  • Whether the 2026-04-21 last commit date reflects actual recent development or is a data anomaly given the 2020-06-22 latest release.
  • Current test coverage and CI/CD status to assess code quality beyond the repository star count.
HTML parser PythonWHATWG HTML parsingparse HTML to treeHTML5 compliant parserweb scraping HTML parsingHTML document parsing libraryElementTree HTML parsing

Similar packages