html5lib
HTML parser based on the WHATWG HTML specification
Install
html5lib on PyPI
pip
pip install html5libuv
uv add html5libpoetry
poetry add html5libPackage 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
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.
Similar packages
permissive · top 1,000 on PyPI
webencodingspermissive · top 1,000 on PyPI
bleachpermissive · top 1,000 on PyPI
sixpermissive · top 100 on PyPI
requests-filepermissive · top 1,000 on PyPI
zope.eventunclear · top 1,000 on PyPI
imagesizepermissive · top 1,000 on PyPI
azure-commonpermissive · top 1,000 on PyPI
seleniumpermissive · top 1,000 on PyPI
charset-normalizerpermissive · top 100 on PyPI