A pure Python HTML5 parser that just works.
Actively maintained. Last release 7 days ago, commits in 19 of the last 26 weeks. A safe choice.
pip install justhtmlJustHTML
HTML from the real web is messy. It is often malformed, user supplied, scraped from unknown pages, or headed for a browser where small parsing differences can become security bugs.
JustHTML gives Python projects one small dependency for the common HTML jobs:
- parse HTML like a browser, including broken markup
- sanitize untrusted HTML by default
- query with CSS selectors
- transform, serialize, extract text, or convert to Markdown
- run anywhere Python runs, with no C extension and no system package to install
pip install justhtml
Requires Python 3.10 or later.
Documentation | Comparison | Playground | Security policy

Why Use It?
Most Python HTML libraries optimize for one part of the problem.
html.parser is built in, but not HTML5-correct. BeautifulSoup is convenient, but depends heavily on the parser underneath. lxml and C/Rust-backed parsers are fast, but usually leave sanitization as a separate concern. html5lib and Bleach shaped the Python ecosystem, but both are no longer the obvious foundation for new projects.
JustHTML is for applications that want a boring, inspectable, pure-Python default:
- Correct parsing: browser-style HTML5 recovery, tested against the web platform html5 treebuilder tests.
- Safe by default:
JustHTML(html)sanitizes before you query or serialize. - One DOM: parse once, then sanitize, query, transform, serialize, extract text, or produce Markdown.
- Easy deployment: zero runtime dependencies, no compiler, works on PyPy and Pyodide.
- Honest tradeoff: if you are parsing terabytes of trusted HTML, use a C/Rust parser. If you need reliable handling of untrusted or malformed HTML inside a Python app, use JustHTML.