Bleach

Allowlist-based HTML sanitizing library for untrusted text

Library
PyPI
v6.4.0
2,765 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
45 /100 Fair
Development Activity 12
Maintenance 0
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
70 /100 Good
Architecture 72
Code Quality 74
Innovation 55
Learning Curve 80

Bleach is Mozilla’s allowlist-based HTML sanitizer: it escapes or strips markup and attributes that aren’t explicitly permitted, rather than trying to blocklist dangerous patterns. It’s built on html5lib for browser-accurate HTML parsing, so it handles unbalanced or mis-nested tags in untrusted input the same way a real browser would, and it can safely linkify plain text into anchor tags with configurable rel attributes.

As of June 2026, the Bleach maintainers have announced the project is no longer maintained, including for security issues, and point users toward Rust-backed alternatives such as nh3. It remains widely deployed and its source stays available on GitHub, so it’s documented here as-is for teams maintaining existing integrations or evaluating a migration path.

What You Get

  • bleach.clean() for allowlist-based sanitization of tags, attributes, and protocols
  • bleach.linkify() for safely converting plain-text URLs and emails into anchor tags
  • A Cleaner/Linker class-based API for reusable, configured sanitizer instances
  • Optional CSS property sanitization via css_sanitizer.py for inline style attributes
  • Browser-accurate HTML5 parsing (via html5lib) that correctly handles malformed/mis-nested markup

Common Use Cases

  • Sanitizing user-submitted comments, forum posts, or wiki content before rendering as HTML
  • Stripping disallowed tags/attributes from rich-text editor output before storage or display
  • Auto-linkifying plain-text URLs in user content while controlling rel/target attributes
  • Cleaning HTML email bodies before displaying them inline in a web app

Under The Hood

Architecture: bleach/sanitizer.py implements the Cleaner class, which drives an html5lib tree-walker/serializer pipeline configured with allowlists for tags, attributes, and protocols; bleach/linkifier.py implements a separate Linker/LinkifyFilter pass for text-to-anchor conversion, and bleach/html5lib_shim.py vendors compatibility shims over html5lib internals the library depends on directly (the package even vendors a _vendor copy of html5lib to pin exact parsing behavior).

Tech Stack: Pure Python with a hard dependency on html5lib for spec-compliant HTML5 parsing; a vendored copy under bleach/_vendor insulates the sanitizer from upstream html5lib API changes, at the cost of needing to be updated manually for html5lib security fixes — a factor the maintainers cite in their deprecation notice.

Code Quality: Seven dedicated test modules (tests/test_clean.py, tests/test_linkify.py, tests/test_css.py, etc.) exercise allowlist edge cases, malformed-HTML handling, and linkify corner cases; the README explicitly documents a responsible security-disclosure process reflecting its history as a security-critical dependency across the Python web ecosystem.

API Design: The API is intentionally small and function-first — bleach.clean(text, tags=..., attributes=...) and bleach.linkify(text) cover the overwhelming majority of use cases in one call, with the Cleaner/Linker classes available only when an application needs to reuse the same configuration repeatedly without re-specifying allowlists.

Used by 9 apps in this directory

Python
68%
MIT

ArchiveBox

Bookmarks Archiving

28,636

Self-hosted web archiving that saves HTML, PDFs, screenshots, media, and code in open formats you own forever

View details
88
Repo Health
84
Technical
69
Dependency
Built with
Python 68%
HTML 25%
Updated 4 days ago
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,125

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
61
Dependency
Built with
Python 59%
Jupyter Notebook 21%
Updated 1 weeks ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 4 days ago
TypeScript
50%
Other

Dify

AI Development · Design Tools · Developer Tools

157,364

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript 50%
Python 47%
Updated 4 days ago
HTML
46%
LGPL-2.1

Horilla

ERP · Human Resources

1,437

Open-source HRMS covering recruitment, attendance, payroll, and biometrics in one self-hosted Django application.

View details
91
Repo Health
60
Technical
65
Dependency
Built with
HTML 46%
Python 38%
JavaScript 12%
Updated 4 days ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,358

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 4 days ago
Python
63%
GPL 3.0

Paperless-ngx

Bookmarks Archiving

46,108

Turn your paper pile into a searchable digital archive with OCR, AI classification, and automated workflows — all running on your own server.

View details
91
Repo Health
88
Technical
67
Dependency
Built with
Python 63%
TypeScript 28%
Updated 4 days ago
Python
54%
AGPL 3.0

Speakr

AI Assistants

4,030

Self-hosted AI transcription with speaker diarization, smart tagging, and multi-user collaboration — your recordings stay on your infrastructure.

View details
82
Repo Health
79
Technical
70
Dependency
Built with
Python 54%
HTML 24%
JavaScript 19%
Updated 1 weeks ago
Python
97%
MPL 2.0

Taiga Back

Developer Tools · Project Management

854

Self-hosted agile project management backend with Scrum, Kanban, issue tracking, and a full REST API — built on Django and PostgreSQL.

View details
76
Repo Health
74
Technical
64
Dependency
Built with
Python 97%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers