Elestia Open Source Ratings
8.7

DOMPurify

A strong pick. 1st of 10 web security libraries.

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.

WebsiteGitHubnpm

Scores

Overall8.7

How strongly do we recommend it for a new project today?

Claude Opus 5.5: 8.5, likely 8.0 to 9.0

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, likely 7.7 to 9.6

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 many4.9

How many developers need a tool for this job?

Claude Opus 5.5: 5.0, likely 4.0 to 6.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.

  • category job: HTML cleaning is one of three jobs in the category
  • dependents.repos: 56,633 repos, well below cors and Helmet

GPT-6.2 Sol: 4.8, likely 3.5 to 6.1

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 lot9.0

How well does it do the job for those who need it?

Claude Opus 5.5: 9.0, likely 8.0 to 9.5

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, likely 7.7 to 9.7

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 time8.3

Will it still be a good choice in two years?

Claude Opus 5.5: 8.5, likely 7.5 to 9.0

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, likely 6.9 to 9.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 widely7.1

How many use it, and is that growing?

Claude Opus 5.5: 8.0, likely 7.0 to 9.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.

  • npm downloadsLast4Weeks: 401.8M vs 58.3M a year ago (6.9x)
  • dependents: 56,633 repos, 1,705 packages
  • github stars: 17,540, the highest among peers

GPT-6.2 Sol: 6.2, likely 5.0 to 7.4

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 for8.6

Who stands behind it being good?

Claude Opus 5.5: 8.5, likely 7.5 to 9.0

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, likely 7.6 to 9.6

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.

Safe8.1

How safe is it to depend on?

Claude Opus 5.5: 8.0, likely 7.0 to 9.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, likely 7.1 to 9.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

npm downloads, 4 weeks
402M ×6.9 in a year
GitHub stars
18k
Commits, 12 months
353
npm version
3.4.18 Nov 2026
Versions, 12 months
23
Advisories, 24 months
26 of 33 ever
OpenSSF Scorecard
9.8 out of 10, Nov 2026
Licence
Apache-2.0

Read on 21 November 2026 from GitHub (cure53/DOMPurify), npm (dompurify), OSV and the OpenSSF Scorecard.

Web security libraries

  1. 8.7DOMPurify
  2. 8.2Helmet
  3. 7.9express-rate-limit
  4. 7.6cors
  5. 7.4rate-limiter-flexible
  6. 7.0Upstash Ratelimit
  7. 6.8sanitize-html
  8. 6.1csrf-csrf
  9. 5.7Arcjet
  10. 5.0js-xss
Compare all 10 on six scores