nh3 provides Python bindings for the Ammonia HTML sanitization library. Use it to clean untrusted HTML, with a benchmark in the project README reporting faster performance than the deprecated Bleach package.
Project status
- Actively maintained: the upstream was pushed on 2026-10-27, and the latest listed update is from 2026-08-24.
- Updates have been frequent in 2026, roughly every one to two months, though there has been a gap of about two months since the latest listed update.
AI summary generated
Recent updates
v0.3.7
nh3 v0.3.7 adds an `id_prefix` option to the Python API and rejects configurations where `attributes` would override a `tag_attribute_values` restriction. It also updates ammonia and PyO3 dependencies and removes reliance on PyO3's deprecated `generate-import-lib` feature.
BreakingFeaturesv0.3.6
v0.3.6 adds `url_relative` configuration to `Cleaner` and `clean`, exposes `nh3.escape` as an alias for `clean_text`, and validates conflicting `clean_content_tags` settings. It also updates PyO3 and refreshes several locked Rust dependencies.
Featuresv0.3.5
nh3 v0.3.5 adds an optional `tags` argument to `clean_text`, allowing selected HTML tags to be preserved without their attributes. It also expands usage examples and doctest coverage, and updates PyO3 from 0.28.2 to 0.28.3.
Featuresv0.3.4
nh3 v0.3.4 adds validation for conflicts between the `rel` attribute and `link_rel`, exposes the default clean-content tags as `CLEAN_CONTENT_TAGS`, and broadens the collection types supported by the type stubs. The code also updates PyO3 and other locked dependencies, and refreshes artifact actions used by CI.
BreakingFeaturesv0.3.3
v0.3.3 adds a RISC-V 64-bit Linux build target and updates PyO3 to 0.28.0. The code diff shows no changes to the Python-facing API, but it also includes undocumented documentation-build, CI workflow, and transitive dependency updates.
Featuresv0.3.2
v0.3.2 updates GitHub Actions and adds CI builds for Python 3.14 free-threaded wheels, along with a README reference in package metadata. The code also upgrades PyO3 and moves the Rust crate to edition 2024, changes the free-threaded wheel build target from Python 3.13 to 3.14, and updates Rust dependencies.
BreakingFeaturesv0.3.1
nh3 v0.3.1 updates its ammonia and PyO3 dependencies. The code diff shows no changes to sanitizer behavior or public function signatures, but it also moves Cleaner option documentation from its method implementation to the class declaration.
v0.3.0
v0.3.0 adds a reusable Python `Cleaner` class that accepts sanitizer configuration at construction and exposes a `clean(html)` method. The existing module-level `clean` API remains declared in the type stub, and the diff shows no documented or apparent breaking API changes.
Featuresv0.2.22
v0.2.22 adds CSS class and inline-style filtering options to `nh3.clean` and adds Windows ARM64 wheel builds. The diff also upgrades the Rust dependencies and expands the lockfile; no breaking changes to the existing Python call signature were identified.
Featuresv0.2.21
v0.2.21 adds two documentation examples and updates the PyO3 dependency. The code diff also changes CI wheel-building and artifact handling, and updates several locked Rust dependencies, but does not show changes to nh3's runtime API.
Features