sanitize-html
JavaScript library that cleans user-submitted HTML, keeping allowlisted elements and attributes and discarding the rest.
sanitize-html is a JavaScript library that cleans user-submitted HTML. A caller lists the tags and the attributes per tag to permit, and the library discards the rest. The README names HTML from rich text editors, including CSS pasted from Word, as typical input.
The 2.x line no longer ships a build for the browser, so browser use means including the package in the project’s own bundle.
Worth knowing
The standalone repository is archived and points to the monorepo, where the package sits in its packages/sanitize-html directory. The README’s Node.js support statement is older than the requirement in the published package.
Identity
Rendering and deploy
- Install with
- npm2
Releases
Adoption
Sources
- 2026-11-16: links, Written in, GitHub stars
api.github.com/repos/apostrophecms/apostrophe - 2026-11-16: links, Categories, Runtime, Install with
raw.githubusercontent.com/apostrophecms/apostrophe/main/packages/sanitize-html/README.md - 2026-11-16: Maintainer
raw.githubusercontent.com/apostrophecms/apostrophe/main/packages/sanitize-html/LICENSE - 2026-11-16: Minimum runtime
registry.npmjs.org/sanitize-html/latest - 2026-11-16: License, License model
raw.githubusercontent.com/apostrophecms/apostrophe/main/packages/sanitize-html/package.json - 2026-11-16: First release, Last release
registry.npmjs.org/sanitize-html - 2026-11-16: Current major version
api.github.com/repos/apostrophecms/apostrophe/tags - 2026-11-16: Contributors
api.github.com/repos/apostrophecms/apostrophe/contributors?per_page=1 - 2026-11-16: npm downloads a week
api.npmjs.org/downloads/range/2026-11-01:2026-11-07/sanitize-html - 2026-11-16: Dependent packages, Dependent repositories
packages.ecosyste.ms/api/v1/registries/npmjs.org/packages/sanitize-html