# Sanitize

Ruby library that cleans HTML and CSS strings by keeping only the elements, attributes and properties on an allowlist.


Source: https://findsoftware.frbit.cloud/ruby-sanitize/
Last reviewed: 2026-11-16
Listed since: 2026-11-16

## Record

### Links

- repository: https://github.com/rgrove/sanitize
- docs: https://rubydoc.info/gems/sanitize/Sanitize

### Identity

- status: active
- maintainer: Ryan Grove
- maintainerType: individual
- parent: unknown
- firstRelease: 2008
- hqCountry: unknown

### Kind

- category: library
- hosting: ruby
- language: ruby
- runtime: ruby
- runtimeMin: ruby 3.2
- basedOn: unknown

### Content

- contentStore: not applicable
- databases: not applicable
- adminUi: not applicable
- headlessApi: not applicable
- templating: not applicable
- i18n: not applicable

### Rendering and deploy

- runsAs: not applicable
- renderingModes: not applicable
- installMethod: gem

### License

- licenseModel: open-source
- license: MIT

### Releases

- currentMajor: 7
- latestReleaseDate: 2026-11-02

### Adoption

- githubStargazers: 2054
- packagistDownloads: not applicable
- npmWeeklyDownloads: not applicable
- contributors: 41
- pluginCount: unknown
- packagistMonthlyDownloads: unknown
- ecosystemsMonthlyDownloads: unknown
- httpArchiveSites: unknown
- wordpressActiveInstalls: unknown
- dependentRepos: 10715
- dependentPackages: 260

### Sources

- urls: https://api.github.com/repos/rgrove/sanitize (read 2026-11-16)
- urls: https://raw.githubusercontent.com/rgrove/sanitize/main/README.md (read 2026-11-16)
- maintainer: https://raw.githubusercontent.com/rgrove/sanitize/main/LICENSE (read 2026-11-16)
- language: https://api.github.com/repos/rgrove/sanitize (read 2026-11-16)
- category: https://raw.githubusercontent.com/rgrove/sanitize/main/README.md (read 2026-11-16)
- runtime: https://github.com/rgrove/sanitize/blob/v7.0.2/sanitize.gemspec (read 2026-11-16)
- runtimeMin: https://github.com/rgrove/sanitize/blob/v7.0.2/sanitize.gemspec (read 2026-11-16)
- installMethod: https://raw.githubusercontent.com/rgrove/sanitize/main/README.md (read 2026-11-16)
- license: https://github.com/rgrove/sanitize/blob/v7.0.2/sanitize.gemspec (read 2026-11-16)
- licenseModel: https://raw.githubusercontent.com/rgrove/sanitize/main/LICENSE (read 2026-11-16)
- firstRelease: https://api.github.com/repos/rgrove/sanitize/commits/release-1.0.0 (read 2026-11-16)
- currentMajor: https://api.github.com/repos/rgrove/sanitize/releases/latest (read 2026-11-16)
- latestReleaseDate: https://api.github.com/repos/rgrove/sanitize/releases/latest (read 2026-11-16)
- githubStargazers: https://api.github.com/repos/rgrove/sanitize (read 2026-11-16)
- contributors: https://api.github.com/repos/rgrove/sanitize/contributors?per_page=1 (read 2026-11-16)
- dependentPackages: https://packages.ecosyste.ms/api/v1/registries/rubygems.org/packages/sanitize (read 2026-11-16)
- dependentRepos: https://packages.ecosyste.ms/api/v1/registries/rubygems.org/packages/sanitize (read 2026-11-16)

## Notes

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.

---

Data licensed CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Attributes are recorded, never scored; absent means unknown.
Credit, in full: FindSoftware, CC BY 4.0
