# DOMPurify: 8.7 out of 10

A strong pick. 1st of 10 in [Web security libraries](https://elestia.ai/opensource/web-security/index.md).

DOMPurify is the standard HTML, SVG and MathML sanitizer for JavaScript. It comes from the security firm Cure53, is very actively maintained and is safe by default. For cleaning untrusted HTML it is the one to pick today, in the browser and, with jsdom, on the server.

**Best for:** Any app that has to render HTML from users, markdown or third parties without opening an XSS hole, especially in the browser.

## Scores

- **Overall: 8.7** (likely 7.9 to 9.3)
  - Claude Opus 5.5 (8.5): It is the best tool for HTML sanitization: secure defaults, quick security fixes, and Google's backing as the fallback for the native API. It loses points for the clumsy jsdom setup on servers, the constant need to upgrade for advisories, and the long-term threat from native setHTML. Among the HTML sanitizers in the bundle, it ranks clearly above sanitize-html and js-xss.
  - GPT-6.2 Sol (8.8): DOMPurify is my first choice among these peers for new browser projects that render untrusted markup. Its tested defaults, flexible output, and active patching support that choice. For HTML-only processing on Node, sanitize-html is simpler to deploy because it supplies its own parser. Dependence on one npm publisher and the cost of a server-side DOM keep the recommendation strongest in browsers.
- **Needed by many: 4.9** (likely 3.8 to 6.1)
  - Claude Opus 5.5 (5.0): Only apps that render untrusted or user-written HTML, such as markdown, rich text, emails or embeds, need an HTML sanitizer. That is a sizable group, but well below all web apps. It covers only the HTML-cleaning part of the category, not headers or rate limits.
  - GPT-6.2 Sol (4.8): HTML sanitization is a recurring need for editors, previews, and apps that render user-supplied markup. DOMPurify works across browser frameworks, and server use requires a DOM implementation. The share of JavaScript projects that render untrusted rich markup is hard to measure.
- **Helps a lot: 9.0** (likely 7.9 to 9.6)
  - Claude Opus 5.5 (9.0): It is secure by default, covers HTML, SVG and MathML, and has hooks and Trusted Types support. It ships its own types and is well documented. Using the native DOM parser avoids the parser-mismatch problems of string-based sanitizers like sanitize-html and js-xss. The main limit is the server side, where it needs jsdom, which is heavy and sometimes fragile.
  - GPT-6.2 Sol (8.9): Version 3.4.18 combines strong browser defaults with SVG and MathML support, configurable hooks, and Trusted Types output. Bundled types and short examples make routine integrations easy for developers and coding agents to check. An independent Node benchmark found sanitize-html and js-xss faster in its test setup. Current cross-runtime performance and the reliability of agent-written custom policies remain uncertain.
- **Holds up over time: 8.3** (likely 7.2 to 9.1)
  - Claude Opus 5.5 (8.5): The last year shows 353 commits, 23 releases, zero open issues or PRs, and steady patch releases without breaking changes. A security consultancy backs it, but releases depend on a small core around one lead maintainer. The native Sanitizer API is a long-term substitute in the browser, but Safari lacks it and Chrome itself points to DOMPurify as the fallback.
  - GPT-6.2 Sol (8.1): The project shipped 23 releases on 353 commits in the past year, and a recent release PR was reviewed and merged the same day. Updates mostly stayed in the 3.x line, with a CommonJS declaration fix in 3.4.16. npm publishing depends on one maintainer, and the level of sponsorship is unclear. Growing support for the native browser sanitizer could reduce demand for basic browser use.
- **Used widely: 7.1** (likely 6.0 to 8.2)
  - Claude Opus 5.5 (8.0): It has about 400M downloads in 4 weeks, up 6.9x on a year ago, above the 4.1x median. Many of these are transitive installs through tools like Mermaid, Monaco and PDF libraries. It has 56.6k dependent repos, fewer than sanitize-html or js-xss, but much use comes from CDNs and bundled copies. It is still the leading HTML sanitizer, with 17.5k stars, the most in the category.
  - GPT-6.2 Sol (6.2): Four-week downloads rose 6.9× year over year, ahead of the 4.1× catalog median and both sanitizer peers. Ecosyste.ms found 56,633 dependent repositories and 1,705 packages, with more tracked repositories for both sanitize-html and js-xss. DOMPurify drew the most Bluesky links among peers, though the leading posts came from its maintainers. CI and transitive installs inflate download totals, and vendored copies make some use invisible to npm.
- **Vouched for: 8.6** (likely 7.6 to 9.3)
  - Claude Opus 5.5 (8.5): Chrome's own security guidance names it as the fallback sanitizer, and major projects such as Monaco and Mermaid build on it. Independent researchers fuzz and audit it all the time. New rivals measure themselves against it. Surveys say little about this niche, so the range stays at one point either way.
  - GPT-6.2 Sol (8.7): OWASP recommends DOMPurify, and Grafana, VS Code, and Mermaid use it in rendering code. Independent comparisons give useful evidence about its browser defaults and server-side tradeoffs. The comparisons cover older versions, and State of JavaScript provides no DOMPurify satisfaction rating.
- **Safe: 8.1** (likely 7.1 to 9.1)
  - Claude Opus 5.5 (8.0): The OpenSSF Scorecard is 9.8, with signed releases, fuzzing and pinned dependencies, and the package has one dependency. The licence is permissive (MPL-2.0 or Apache-2.0). The bundle shows 26 advisories in 24 months. The recent ones are low severity, in niche modes, and fixed quickly, but the steady flow means users must upgrade often.
  - GPT-6.2 Sol (8.2): Recent upstream disclosures had patches available at publication, including the November fix in 3.4.18 and an October follow-up to an incomplete fix. The browser package has one optional type dependency and offers a choice of Apache-2.0 or MPL-2.0. The 9.8 OpenSSF Scorecard reflects strong review, fuzzing, and signed releases, with branch protection at 8 and packaging unscored. Recurring bypasses, manual publishing by one maintainer, and reliance on an up-to-date DOM on the server widen the range.

## Good

- Safe defaults with no setup: DOMPurify.sanitize(dirty) is enough for most uses.
- A security firm maintains it, with constant fuzzing and hardening, and bypasses get fixed within days.
- It uses the browser's own parser, which avoids parser mismatches and makes it fast and small client-side.
- It has hooks, Trusted Types support and fine-grained configuration for advanced cases.

## Bad

- On Node it needs jsdom, which is heavy, can leak memory in long-running processes and has had ESM/CJS breakage.
- It gets a steady stream of bypass advisories (26 in two years), so you must keep upgrading. Most are low severity and in niche modes such as IN_PLACE or RETURN_DOM.
- The native Sanitizer API (setHTML) may cut the need for it in the browser over time.
- It covers only HTML cleaning, not headers, CORS or rate limits.

## The numbers

- Downloads, 4 weeks: 402M
- In a year: ×6.9
- GitHub stars: 18k
- Commits, 12 months: 353
- Last npm release: Nov 2026
- Advisories, 24 months: 26
- Licence: Apache-2.0
- GitHub: https://github.com/cure53/DOMPurify
- npm: https://www.npmjs.com/package/dompurify

Scores run from 0 to 10 and are the mean of the scores of AI reviewers (Claude Opus 5.5, GPT-6.2 Sol), made on 22 November 2026 from GitHub, npm, OSV, OpenSSF Scorecard, ecosyste.ms, Hacker News and Bluesky data and a web search. The ecosyste.ms count of repositories that use a project is far too low for projects that grew in the last few years, and some reviews quote it. Overall is the reviewers' own judgement for a new project today, not an average of the parts. An AI wrote them and can be wrong.
