Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Python
  3. justhtml

justhtml

NOASSERTIONPythonv3.11.2

A pure Python HTML5 parser with spec-perfect parsing, built-in sanitization, CSS selectors, and zero dependencies.

Visit WebsiteGitHubGitHub
1.2k stars44 forks0 contributors

What is justhtml?

JustHTML is a pure Python HTML5 parser that provides spec-compliant parsing with browser-grade error recovery. It solves the problem of parsing and manipulating HTML in Python without requiring C extensions or complex dependencies, offering built-in security features like sanitization and a simple query API with CSS selectors.

Target Audience

Python developers who need to parse, sanitize, query, or transform HTML documents, especially those working in environments where installing C extensions is difficult or where security and correctness are priorities.

Value Proposition

Developers choose JustHTML for its combination of spec-perfect HTML5 compliance, built-in sanitization, zero dependencies, and pure Python implementation, making it easy to install, debug, and use across different platforms while maintaining robust security and correctness.

Overview

A pure Python HTML5 parser that just works. No C extensions to compile. No system dependencies to install. No complex API to learn.

Use Cases

Best For

  • Parsing and sanitizing user-generated HTML content safely
  • Web scraping with CSS selector queries and error-tolerant parsing
  • Building HTML documents programmatically in Python
  • Transforming HTML documents with built-in DOM manipulation
  • Environments where C extensions or system dependencies are problematic
  • Educational projects or tools requiring a simple, correct HTML parser

Not Ideal For

  • High-throughput web scraping of terabytes of data requiring maximum parsing speed
  • Projects needing XPath queries for legacy or complex document navigation
  • Environments stuck on Python versions older than 3.10

Pros & Cons

Pros

Spec-Perfect Parsing

Passes the official html5lib-tests suite with 100% coverage, ensuring browser-grade error recovery for malformed HTML, as demonstrated in the correctness documentation.

Built-in Security

Includes safe-by-default Bleach-style sanitization at construction time, with support for inline CSS rule sanitization, making it secure for user-generated content out of the box.

CSS Selector Queries

Provides query() and query_one() methods with familiar CSS selector syntax, simplifying document traversal and manipulation without external dependencies.

Zero Dependencies

Pure Python implementation with no C extensions or system libraries, easy to install and debug across platforms like PyPy and Pyodide, as highlighted in the installation notes.

Cons

Performance Trade-off

Admits in the benchmarks that for terabyte-scale parsing, C/Rust parsers like html5ever are better, as it's optimized for common cases but slower than native alternatives.

Sanitization Order Limitation

Sanitization happens before querying, which can be inconvenient when working with safe HTML, requiring explicit disabling with sanitize=False, as noted in the query examples.

Limited Advanced Features

Lacks support for XPath queries and other advanced parsing tools found in libraries like lxml, focusing solely on CSS selectors and HTML5 compliance.

Frequently Asked Questions

Quick Stats

Stars1,155
Forks44
Contributors0
Open Issues0
Last commit11 days ago
CreatedSince 2024

Tags

#dom-manipulation#sanitization#pure-python#python-library#css-selectors#html5#zero-dependencies#security#html#python#web-scraping#html-parser#parser

Built With

P
Python

Links & Resources

Website

Included in

Python290.8k
Auto-fetched 5 hours ago

Related Projects

xmltodictxmltodict

Python module that makes working with XML feel like you are working with JSON

Stars5,754
Forks475
Last commit19 days ago
lxmllxml

The lxml XML toolkit for Python

Stars3,055
Forks636
Last commit3 days ago
pyquerypyquery

A jquery-like library for python

Stars2,377
Forks187
Last commit1 month ago
markupsafemarkupsafe

Safely add untrusted strings to HTML/XML markup.

Stars697
Forks184
Last commit11 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub