DOMPurify
3.4.15 open-sourceThe section your link pointed to isn't on DOMPurify's page any more, so we've brought you to the top.
DOMPurify - a DOM-only, super-fast, uber-tolerant XSSXSSCross-site scripting, an attack that runs malicious script in another user's browser through a trusted site. It can steal data or perform actions using the user's session. sanitizer for HTML, MathML and SVG. DOMPurify works with a secure default, but offers a lot of configurability and hooks. Demo:
DOMPurify.sanitize(dirty, {
ADD_ATTR: (attr) => attr.startsWith('data-myapp-')
});
DOMPurify.sanitize(dirty, {
ADD_TAGS: (tag) => tag.startsWith('myapp-')
});
DOMPurify.sanitize(dirty, {
CUSTOM_ELEMENT_HANDLING: {
attributeNameCheck: (attrName, tagName) => {
// Only allow 'data-tooltip' on <my-button>, block it everywhere else
if (attrName === 'data-tooltip' && tagName === 'my-button') return true;
return false;
}
}
});
// Previously you could only removeAllHooks(); now remove just one:
DOMPurify.removeHook('beforeSanitizeElements');
const clean = DOMPurify.sanitize('<math><menclose mprescripts>...</menclose></math>');
const clean = DOMPurify.sanitize('<a href="sms:5551234">Text us</a>');
const clean = DOMPurify.sanitize('<img src="x" alt="y">', { ALLOW_SELF_CLOSE_IN_ATTR: true });
const clean = DOMPurify.sanitize(html, { shadowrootmode: 'open' });
const clean = DOMPurify.sanitize(dirty, {
ALLOWED_NAMESPACES: ['http://www.w3.org/2000/svg', 'http://www.w3.org/1998/Math/MathML']
});
const clean = DOMPurify.sanitize(dirty, {
SAFE_FOR_TEMPLATES: true
});
grep -i 'license' dist/purify.min.js
const clean = DOMPurify.sanitize(rawHtml, { FORCE_BODY: true });
const cleaned = DOMPurify.sanitize(htmlString);
console.log(DOMPurify.removed);
const clean = DOMPurify.sanitize(dirty, { SAFE_FOR_TEMPLATES: true });
DOMPurify.sanitize(html, { FORBID_TAGS: ['script'], FORBID_ATTR: ['onerror'] });
DOMPurify.addHook('uponSanitizeElement', (hookEvent, config) => { /* logic */ });
Summary
DOMPurify is an open-source (MPL-2.0 or Apache-2.0) JavaScript library that sanitizes HTML, MathML and SVG to strip out cross-site-scripting payloads before they reach the DOM. It's imported directly into application code rather than run as a service, and it works across all modern browser engines (Blink, Gecko, WebKit), degrading harmlessly on legacy ones like older MSIE. It's aimed at application developers who need to render untrusted or user-supplied markup safely, and its allow-lists for tags, attributes and URI schemes can be tuned or extended with functions as a project's components grow. It sits in the web-app-security space alongside other DOM sanitization approaches, with configuration hardening added specifically against prototype-pollution attacks on the sanitizer itself. First committed in 2014, it remains active with 143 contributors, 324 commits and 22 releases in the past year, the latest just 18 days ago.
DOMPurify - a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. DOMPurify works with a secure default, but offers a lot of configurability and hooks. Demo:
How DOMPurify helps
Is this chunk of user-supplied markup safe to drop into the page?
runs it through the allow-lists for tags, attributes and URI schemes and returns a cleaned string or DOM node with anything dangerous stripped out, so what comes back can be inserted directly
Can a crafted attribute or tag sneak a script past this sanitizer?
matches every tag, attribute and scheme against its allow-list rather than trying to pattern-match known exploits, so unrecognized constructs are dropped by default instead of passed through
Does my custom UI markup still get through after sanitizing?
lets tags, attributes and custom elements be allowed dynamically through functions, so a growing component library can be permitted by name or pattern instead of hand-listing every case
Could someone attack the sanitizer's own configuration rather than the page?
hardens its configuration handling against prototype-pollution attempts, so tampering with the config object itself doesn't change what gets sanitized
Will this markup still be safe once it's mutated by the browser after insertion?
includes scrubbing behavior aimed at mutation-based XSS, where content that looks clean becomes dangerous only after the DOM parses and mutates it
Is a link using an unusual URI scheme actually safe to render?
checks the scheme against its allow-list of accepted protocols and strips the link if the scheme isn't recognized
Languages
Command line
No command matches.
| option | found in | since | description |
|---|
Values are placeholders taken from each option’s declared default. Nothing is executed here — the output shown is a recording of a run that already happened.
Score card
-
Shipping velocity releases a month, last 12 months
-
Documentation quality release-notes rubric, 0–100
-
Breaking-change discipline how rarely a release breaks users, and notice given
-
Maintenance risk quiet time against its own cadence, maintainers
-
Innovation & surface new capabilities, API and MCP surface
- Community health
-
Contributor trend distinct committers, this year against last
-
Maintainer concentration bus factor now against a year ago
-
Issue backlog trend issues closed per issue opened, 12 months
-
Responsiveness median time to a maintainer’s first reply
Nine scores for DOMPurify, each built from the releases, notes and API history this site tracks — and, on Researcher and Business, where it stands among every measured tool in its category and how that has moved.
Score cards are part of every paid plan.
See plans → Already subscribed? Sign in →Trajectory
Blank means never measured; nothing here is a filled-in zero.
Peer standings are included with Researcher and Business. See how this tool ranks against its competitors, using data we don't publish anywhere else.
See plans →Each score is 0–100 on a published rubric, derived from data this site already shows. A dimension we cannot measure says so — it is never scored 0 and never enters a rank.
How this is scored
- Shipping velocity — releases a month over the last 12 months, on a log scale where 16 a month scores 100. Needs 3 releases in the window.
- Documentation quality — the release-notes rubric published on the analytics page, unchanged.
- Breaking-change discipline — the share of releases carrying a breaking change (none scores 100, half or more scores 0). Only projects that label breaking changes are measured: a clean record cannot be told from an unlabelled one.
- Maintenance risk — quiet time measured against the tool's own release cadence (quiet longer than 90 days and three typical gaps scores 0), plus the number of active maintainers and whether contributors are growing, where known. Higher is lower risk.
- Innovation & surface — new capabilities in the feature ledger this year, API and MCP operations added, and the share of commits that are features: the mean of whichever we hold.
- Community health (open-source tools only) — each is a direction, not a size: contributors this year against last, the bus factor now against a year ago, and issues closed per issue opened, where steady scores 50, doubled 100 and halved 0; plus the median time to a maintainer's first reply (an hour scores about 100, a month or more 0). A commercial card has no repository and carries none of the four.
- Documented delivery (commercial tools) — when a vendor's documented new capabilities have slowed against its own baseline, that counts against the overall standing as heavily as two low dimensions. Steady delivery, or too little history to judge, leaves the standing alone; it is never a sixth score.
- Open-source tools are scored on repository signals; commercial tools on their published changelog. Ranks compare tools within one category and one profile and need at least five measured peers; the overall standing needs three ranked dimensions. Best-in-breed or consolidator is a shape, not a quality, and is never scored.
Release-note detail over time
See how much detail DOMPurify puts in its release notes, quarter by quarter, and compare it with tracked tools in the same category. This history uses up to ten retained, reviewed notes per tool; sparse or blank older quarters may reflect that limit.
Checking release-note history…
Releases
32 entries
No entries match these filters.
- September 20261
- August 20261
- July 20261
- May 20264
- April 20263
- October 20251
- September 20251
- May 20251
- January 20251
- October 20242
- September 20241
- April 20241
- April 20231
- February 20231
- November 20221
- August 20221
- December 20211
- April 20201
- February 20201
- September 20191
- April 20171
- May 20161
- October 20151
- September 20151
- February 20151
- April 20141
Project health
Issue, contributor and maintainer activity in cure53/DOMPurify, 2023-10 – 2026-09, as of 2026-09-25. Twelve-month figures first; the trend lines run the whole window.
- Contributors 16 −5 vs prior 12 months
- Maintainers 1 +2 joined · −4 left, last 12 months
- Bus factor 1 committers behind half the commits
- Community-filed 100% of issues opened, last 12 months
- Median time to close < 1 day first maintainer reply 12 hours
- Open backlog 0 of 714 issues ever filed
- Issues opened / month 1 · 0 communitymaintainers
- Open backlog 0
- Contributors / month 2
- Commits / month 10
- Stars 17,406
- other 100%
Counts from the project's public repository and git history; no individuals are identified. Maintainers are the committers covering 80% of the last year's commits. how we measure this
Add the badge to your README
Maintain this project? The badge links readers straight to this page, so they can follow every release here.