Python binding to Ammonia HTML sanitizer Rust crate
Project Links
Meta
Author: messense
Requires Python: >=3.8
Classifiers
Programming Language
- Rust
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
Topic
- Software Development :: Libraries :: Python Modules
nh3
Python bindings to the ammonia HTML sanitization library.
Installation
pip install nh3
Usage
See the documentation.
Performance
A quick benchmark showing that nh3 is about 20 times faster than the deprecated bleach package. Measured on a MacBook Air (M2, 2022).
Python 3.11.0 (main, Oct 25 2022, 16:25:24) [Clang 14.0.0 (clang-1400.0.29.102)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import requests
In [2]: import bleach
In [3]: import nh3
In [4]: html = requests.get("https://www.google.com").text
In [5]: %timeit bleach.clean(html)
2.85 ms ± 22.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [6]: %timeit nh3.clean(html)
138 µs ± 860 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
License
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.
0.3.4
Mar 25, 2026
0.3.3
Feb 14, 2026
0.3.2
Oct 30, 2025
0.3.1
Oct 07, 2025
0.3.0
Jul 17, 2025
0.2.22
Jul 15, 2025
0.2.21
Feb 25, 2025
0.2.20
Dec 17, 2024
0.2.19
Nov 29, 2024
0.2.18
Jul 07, 2024
0.2.17
Mar 26, 2024
0.2.16
Mar 26, 2024
0.2.15
Dec 07, 2023
0.2.14
Jul 05, 2023
0.2.13
Jun 03, 2023
0.2.12
May 31, 2023
0.2.11
Apr 22, 2023
0.2.10
Apr 21, 2023
0.2.9
Mar 25, 2023
0.2.8
Feb 08, 2023
0.2.7
Jan 28, 2023
0.2.6
Jan 28, 2023
0.2.5
Jan 28, 2023
0.2.4
Jan 27, 2023
0.2.3
Jan 24, 2023
0.2.2
Jan 18, 2023
0.2.1
Dec 19, 2022
0.2.0
Oct 29, 2022
0.1.2
Feb 12, 2022
0.1.1
Aug 04, 2021
0.1.0
Aug 03, 2021
Wheel compatibility matrix
Files in release
nh3-0.3.4-cp314-cp314t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.4MiB)
nh3-0.3.4-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (772.0KiB)
nh3-0.3.4-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl (817.9KiB)
nh3-0.3.4-cp314-cp314t-musllinux_1_2_aarch64.whl (988.4KiB)
nh3-0.3.4-cp314-cp314t-musllinux_1_2_armv7l.whl (1.0MiB)
nh3-0.3.4-cp314-cp314t-musllinux_1_2_i686.whl (1.0MiB)
nh3-0.3.4-cp314-cp314t-musllinux_1_2_x86_64.whl (1011.7KiB)
nh3-0.3.4-cp314-cp314t-win32.whl (586.3KiB)
nh3-0.3.4-cp314-cp314t-win_amd64.whl (599.0KiB)
nh3-0.3.4-cp314-cp314t-win_arm64.whl (592.8KiB)
nh3-0.3.4-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.4MiB)
nh3-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (814.3KiB)
nh3-0.3.4-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (801.2KiB)
nh3-0.3.4-cp38-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (1.0MiB)
nh3-0.3.4-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (997.9KiB)
nh3-0.3.4-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (891.6KiB)
nh3-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (786.1KiB)
nh3-0.3.4-cp38-abi3-manylinux_2_31_riscv64.whl (813.9KiB)
nh3-0.3.4-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (834.3KiB)
nh3-0.3.4-cp38-abi3-musllinux_1_2_aarch64.whl (998.1KiB)
nh3-0.3.4-cp38-abi3-musllinux_1_2_armv7l.whl (1.1MiB)
nh3-0.3.4-cp38-abi3-musllinux_1_2_i686.whl (1.0MiB)
nh3-0.3.4-cp38-abi3-musllinux_1_2_x86_64.whl (1021.5KiB)
nh3-0.3.4-cp38-abi3-win32.whl (595.3KiB)
nh3-0.3.4-cp38-abi3-win_amd64.whl (609.6KiB)
nh3-0.3.4-cp38-abi3-win_arm64.whl (602.2KiB)
nh3-0.3.4.tar.gz (19.1KiB)
No dependencies