html5rdf
HTML parser based on the WHATWG HTML specification
What it is and what it does
html5rdf is a Python library that parses HTML documents into tree structures suitable for use with RDFLib, the semantic web toolkit. It is a fork of html5lib designed to conform to the WHATWG HTML specification as implemented by major web browsers. The parser accepts HTML from files, strings, or HTTP responses and can output to multiple tree formats—xml.etree (default), lxml.etree, or xml.dom.minidom—allowing flexibility in how you work with the parsed structure.
The library has no runtime dependencies and supports Python 3.8 through 3.12 on both CPython and PyPy (with caveats around lxml). It is intended for developers who need to extract or transform HTML into RDF-compatible structures, particularly when working within the RDFLib ecosystem. Optional dependencies like lxml, genshi, and chardet can enhance functionality for specific use cases.
Use it for:
- Extract structured data from HTML documents for conversion to RDF graphs using RDFLib.
- Parse HTML with WHATWG-compliant error recovery when building semantic web applications.
- Integrate HTML parsing into RDF data pipelines where standard HTML5 compliance is required.
- Use alternative tree builders (lxml, minidom) when specific XML processing workflows are needed.
- Handle HTTP responses with charset detection for proper encoding when fetching remote HTML.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses HTML documents into tree structures compatible with RDFLib, implementing the WHATWG HTML specification and supporting multiple tree builders like xml.etree, lxml, and xml.dom.minidom.
Yes, if you need WHATWG-compliant HTML parsing specifically for RDFLib workflows. The library has low install friction, no runtime dependencies, and permissive licensing. However, the 653-day gap since last release combined with aging maintenance status suggests limited active development—suitable for stable use cases but verify that it meets your RDF integration needs before adopting in new projects.
Install
html5rdf on PyPI
pip
pip install html5rdfuv
uv add html5rdfpoetry
poetry add html5rdfInstalling html5rdf
Before you install
Low install friction with no runtime dependencies. Last release was 653 days ago and the repository shows aging maintenance signals, though the codebase remains archived-free and the last commit is recent.
License in practice
MIT license permits unrestricted use, modification, and distribution with only attribution and liability disclaimer required—suitable for both open and proprietary projects.
Quickstart
import html5rdf
# Parse from file
with open("mydocument.html", "rb") as f:
document = html5rdf.parse(f)
# Or parse from string
document = html5rdf.parse("Hello World!")
# Use alternative tree builder
parser = html5rdf.HTMLParser(tree=html5rdf.getTreeBuilder("lxml"))
lxml_document = parser.parse("<html></html>")
Requires Python 3.8 or later; lxml tree builder is not supported on PyPy due to known segfault issues.
Verify before relying
- Whether the 653-day gap since last release indicates active maintenance or dormancy despite recent commits.
- Performance characteristics compared to other HTML parsers for large documents.
- Specific RDFLib integration patterns and whether this is the standard approach for RDF extraction from HTML.
Package facts
| License | Copyright (c) 2006-2013 James Graham and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 653 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 862,453/month — #4,869 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: html5rdf-1.2.1-py2.py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
html5libhtml5lib parses HTML documents into a tree…
permissive · top 1,000 on PyPI
tinyhtml5Parses HTML5 documents—including malformed…
permissive · top 1,000 on PyPI
pyrdfa3Parses RDFa markup embedded in HTML documents…
unclear · top 15,000 on PyPI
rdflibRDFLib is a Python library for parsing,…
permissive · top 1,000 on PyPI
CFGraphCFGraph extends rdflib's Graph to read RDF…
permissive · top 15,000 on PyPI
rdflib-jsonldProvides JSON-LD parsing and serialization for…
permissive · top 15,000 on PyPI
turbohtmlParse, query, edit, and serialize HTML and XML…
permissive · top 15,000 on PyPI
PyShExPyShEx parses and validates RDF data against…
permissive · top 15,000 on PyPI
owlrlImplements OWL2 RL Profile and RDFS inference…
unclear · top 5,000 on PyPI
pymanticPymantic parses and queries RDF and semantic…
permissive · top 15,000 on PyPI