13 releases (8 breaking)

Uses new Rust 2024

0.10.0 Oct 20, 2025
0.9.0 May 2, 2025
0.8.1 Jun 2, 2024
0.8.0 Sep 9, 2023
0.2.0 Dec 12, 2017

#1000 in Web programming

Download history 522/week @ 2025-10-26 283/week @ 2025-11-02 600/week @ 2025-11-09 525/week @ 2025-11-16 311/week @ 2025-11-23 546/week @ 2025-11-30 459/week @ 2025-12-07 733/week @ 2025-12-14 309/week @ 2025-12-21 126/week @ 2025-12-28 847/week @ 2026-01-04 584/week @ 2026-01-11 461/week @ 2026-01-18 610/week @ 2026-01-25 868/week @ 2026-02-01 460/week @ 2026-02-08

2,405 downloads per month
Used in 7 crates (4 directly)

MIT license

62KB
1.5K SLoC

HTML Sanitization library

Examples

use sanitize_html::sanitize_str;
use sanitize_html::rules::predefined::DEFAULT;

let input = "<b>Lo<!-- comment -->rem</b> <a href=\"pants\" title=\"foo\">ipsum</a> <a href=\"http://foo.com/\"><strong>dolor</strong></a> sit<br/>amet <script>alert(\"hello world\");</script>";

let sanitized_default: String = sanitize_str(&DEFAULT, input).unwrap();
assert_eq!(&sanitized_default, "Lorem ipsum dolor sit amet ");

Sanitize HTML

Crates.io Status Build codecov dependency status

This is a library for sanitization of HTML fragments.

Dependencies

~3–5MB
~92K SLoC