skillfed

html5rdf

HTML parser based on the WHATWG HTML specification

html5rdf v1.2.1 862.5K downloads/30d#4,869 on PyPI2
Permissive 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) AGING released

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 html5rdf

uv

uv add html5rdf

poetry

poetry add html5rdf

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: HTML

Tags

HTML parser RDFLibWHATWG HTML parsingHTML to RDFHTML tree buildersemantic HTML parsingRDF document extractionHTML5 parser Python
rdf-integrationhtml-parsingsemantic-web

More Python Modules packages