# js-xss: 5.0 out of 10

Reasonable, with limits. 10th of 10 in [Web security libraries](https://elestia.ai/opensource/web-security/index.md).

js-xss (npm `xss`) is a small, whitelist-based HTML sanitizer that runs in Node and the browser and has no DOM dependency. It works and is widely installed, but it parses HTML with string rules rather than a real DOM, has one main maintainer, and leaves bypass reports open for years. For new work, DOMPurify, or sanitize-html on servers, is the safer pick.

**Best for:** Projects that already use it, or that need a tiny HTML filter with a strict whitelist and no DOM, for low-risk content.

## Scores

- **Overall: 5.0** (likely 3.9 to 6.0)
  - Claude Opus 5.5 (4.0): It still works and is light, so keeping it where it already runs is reasonable. For new projects, DOMPurify does the same job with stronger and more actively maintained protection, and sanitize-html is the better-maintained choice on servers. Open bypass reports, maintenance by one person and falling share keep it in 'keep but don't start with it' territory.
  - GPT-6.2 Sol (5.9): js-xss is a reasonable choice when a small, typed string filter needs to work on both the server and the client. DOMPurify is the stronger browser default, and sanitize-html has stronger comparative filtering results for Node.js. Below-median download growth and a long release gap weigh against js-xss for new projects, while the October fixes leave room for a better maintenance outlook if that pace continues.
- **Needed by many: 4.3** (likely 3.2 to 5.4)
  - Claude Opus 5.5 (4.0): Cleaning user-sent HTML is one part of the category's job. It matters to apps that accept rich text, comments or Markdown, not to most projects. js-xss covers only this sanitization part, so its audience is a clear niche.
  - GPT-6.2 Sol (4.5): HTML sanitization serves a clear subset of JavaScript projects, including those that render user posts, rich-text editor output, or imported markup. js-xss works across browsers and Node.js, which broadens its fit. The share of projects that need to preserve untrusted HTML is hard to measure directly.
- **Helps a lot: 5.5** (likely 4.4 to 6.7)
  - Claude Opus 5.5 (4.5): The whitelist API, CSS filtering and types are adequate, and it needs no DOM. However, it parses with strings and regexes rather than a real DOM, and a reported iframe/javascript-scheme bypass (#283) and escaping problems (#267, #291) are still open. DOMPurify does the same job with stronger, better-audited protection, and sanitize-html uses a real parser on servers.
  - GPT-6.2 Sol (6.4): Version 1.0.17 offers a small, typed API with detailed allowlists, callbacks, and a report of filtered markup. The CommonJS package can make named imports fail in native Node.js ES modules. A 2025 comparison found low memory use and fewer blocked test cases than with either sanitizer peer. That comparison predates 1.0.17, and there is little direct evidence on how reliably coding agents configure it.
- **Holds up over time: 4.7** (likely 3.6 to 6.1)
  - Claude Opus 5.5 (4.0): The project is not abandoned: 1.0.16 and 1.0.17 came out in October 2026, and a prototype-pollution fix landed in May. But there were only 11 commits in the year, and nearly all of the work comes from one maintainer working in short bursts, often through AI agents. The 1.0.16 release broke option defaults, and many issues get no reply. Peers have far more active maintenance, and the ecosystem is moving toward DOMPurify.
  - GPT-6.2 Sol (5.4): The repository recorded 11 commits and npm recorded two releases in the past year, both in October 2026 after a gap of more than two years. A user reported production errors after upgrading to 1.0.16, and 1.0.17 fixed the regression two days after the report. Several issues have been open for years, and funding and release coverage remain unclear, so the recent work gives limited confidence about the next two years.
- **Used widely: 6.0** (likely 4.9 to 7.0)
  - Claude Opus 5.5 (5.5): Use is large: about 31M downloads in four weeks and about 111k dependent repos, more than DOMPurify's 57k by the ecosyste.ms count. But downloads grew only 2.3x over the year, well below the 4.1 median, so it is losing ground. Much of the use is likely transitive or comes from older codebases.
  - GPT-6.2 Sol (6.4): Ecosyste.ms found about 111,000 dependent repositories, ahead of both sanitizer peers in this snapshot, and GitHub shows about 5,300 stars. Four-week npm downloads grew from 13.6 million to 31.1 million, or 2.29 times, below the 4.1 times catalog median and both sanitizer peers. Framework integrations can generate installs for users who never chose js-xss directly, so the download trend signals weaker momentum without measuring new adoption on its own.
- **Vouched for: 4.7** (likely 3.6 to 6.0)
  - Claude Opus 5.5 (3.0): I found no current independent audits, benchmarks or named production users that vouch for its quality. Third-party comparisons rank it below DOMPurify and sanitize-html and advise it only for low-risk use. Its many dependents show adoption, not endorsement.
  - GPT-6.2 Sol (6.4): Nuxt Security builds its XSS validator on js-xss, Esri chose it for its ArcGIS HTML sanitizer, and Apache Superset merged a dependency update in October 2026. The independent benchmark gives mixed results, with low memory use alongside weaker default filtering in its test set. State of JavaScript offers no project-specific satisfaction or retention data, and little independent testing covers the current release.
- **Safe: 6.0** (likely 4.9 to 7.4)
  - Claude Opus 5.5 (5.5): The package has a small footprint (two dependencies), an MIT licence and no OSV advisories. Against that, bypass reports have stayed open for years, and a prototype-pollution flaw was fixed in 2026 with no advisory published. The OpenSSF Scorecard is 5.4, with weak checks on token permissions, pinned dependencies, fuzzing and code review, and publishing rests on one maintainer.
  - GPT-6.2 Sol (6.5): The MIT license and two direct runtime dependencies keep the dependency footprint small. The maintainer disclosed a moderate issue affecting custom allowlists that the OSV snapshot missed, and 1.0.16 fixed it before public disclosure. The 5.4 OpenSSF Scorecard flagged weak code review and zero scores for token permissions, pinned dependencies, and fuzzing. Release signing, publishing controls, and the number of authorized publishers remain unclear.

## Good

- It is very light: two dependencies and no DOM or jsdom needed, so it runs the same way in Node and the browser.
- Its whitelist is deny-by-default, and the defaults strip event handlers and `javascript:` URLs.
- It ships TypeScript types and has a simple API: `filterXSS(html, options)`.
- No advisories are recorded in OSV for the last 24 months.

## Bad

- It parses HTML with string rules rather than a DOM, so it is more exposed to mutation XSS than DOMPurify.
- Bypass and escaping reports have stayed open since 2022–2024, for example #283 (an iframe with a `jAva&Tab;script:` src) and #291.
- Work comes from one maintainer in bursts. In 2026 much of it was done through AI agents, and 1.0.16 shipped a regression (issue #304).
- Its share is shrinking: downloads grew 2.3x over the year, against a median of 4.1x, while DOMPurify grew about 6.9x.

## The numbers

- Downloads, 4 weeks: 31M
- In a year: ×2.3
- GitHub stars: 5.3k
- Commits, 12 months: 11
- Last npm release: Oct 2026
- Advisories, 24 months: 0
- Licence: MIT
- GitHub: https://github.com/leizongmin/js-xss
- npm: https://www.npmjs.com/package/xss

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.
