API Reference

sanitize-html

It is well suited for cleaning up HTML fragments such as those created by CKEditor and other rich text editors.

Official Documentation ↗
CompatibilityThis documentation covers version v2.0. Check the official docs for the latest API surface.

Installation

npmnpm install sanitize-html
pnpmpnpm add sanitize-html
yarnyarn add sanitize-html

Methods

Overview

It is well suited for cleaning up HTML fragments such as those created by CKEditor and other rich text editors. It is especially handy for removing unwanted CSS when copying and pasting from Word.

API reference status

This page lists only entry points that appear verbatim in the official README examples: sanitizeHtml, alert. Parameter and return types are not given by the official README, so signatures are marked unverified.

Errors

The following points are quoted verbatim from the official documentation (https://github.com/apostrophecms/sanitize-html). Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted from the official documentation (https://github.com/apostrophecms/sanitize-html); this is not a complete threat model.

Verification notes

FAQ

What does sanitize-html do?
It is well suited for cleaning up HTML fragments such as those created by CKEditor and other rich text editors.
How do I install sanitize-html?
Run `npm install sanitize-html`.
Where can I verify the API details?
Official repository/documentation: https://github.com/apostrophecms/sanitize-html. Checked on 2026-11-04; signatures and return values not stated in the official README are marked unverified.