Sanitize
Ruby library that cleans HTML and CSS strings by keeping only the elements, attributes and properties on an allowlist.
Sanitize is a Ruby library that works as an allowlist-based sanitizer for HTML and CSS: it removes whatever elements, attributes and properties are not on the allowlist. The README says it is built on the Nokogiri HTML5 parser and on Crass, a CSS parser.
Worth knowing
The README warns that Sanitize cannot fully sanitize the contents of math and svg elements, and that it removes them by default.
Identity
- Status
- Active
- Maintainer
- Ryan Grove3
- Maintained by
- Individual
- First release
- 20085
Rendering and deploy
- Install with
- gem2
Releases
Adoption
Sources
- 2026-11-16: links, Written in, GitHub stars
api.github.com/repos/rgrove/sanitize - 2026-11-16: links, Categories, Install with
raw.githubusercontent.com/rgrove/sanitize/main/README.md - 2026-11-16: Maintainer, License model
raw.githubusercontent.com/rgrove/sanitize/main/LICENSE - 2026-11-16: Runtime, Minimum runtime, License
github.com/rgrove/sanitize/blob/v7.0.2/sanitize.gemspec - 2026-11-16: First release
api.github.com/repos/rgrove/sanitize/commits/release-1.0.0 - 2026-11-16: Current major version, Last release
api.github.com/repos/rgrove/sanitize/releases/latest - 2026-11-16: Contributors
api.github.com/repos/rgrove/sanitize/contributors?per_page=1 - 2026-11-16: Dependent packages, Dependent repositories
packages.ecosyste.ms/api/v1/registries/rubygems.org/packages/sanitize