Elestia Open Source Ratings
5.0

js-xss

Reasonable, with limits. 10th of 10 web security libraries.

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.

WebsiteGitHubnpm

Scores

Overall5.0

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

Claude Opus 5.5: 4.0, likely 3.0 to 5.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, likely 4.8 to 7.0

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

How many developers need a tool for this job?

Claude Opus 5.5: 4.0, likely 3.0 to 5.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, likely 3.4 to 5.7

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 lot5.5

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

Claude Opus 5.5: 4.5, likely 3.5 to 6.0

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, likely 5.2 to 7.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 time4.7

Will it still be a good choice in two years?

Claude Opus 5.5: 4.0, likely 3.0 to 5.5

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, likely 4.1 to 6.7

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

How many use it, and is that growing?

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

  • npm downloadsLast4Weeks: 31.1M now, against 13.6M a year ago: a ratio of 2.29.
  • medianDownloadsRatio: Median of 4.1; DOMPurify is about 6.9 and sanitize-html about 4.7.
  • dependents repos: 111,112 repos and 899 packages.
  • bluesky posts / hackerNews stories: Zero for both: little current attention.

GPT-6.2 Sol: 6.4, likely 5.3 to 7.5

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.

  • dependents repos and packages: 111,112 indexed repositories and 899 indexed packages.
  • github stars, hackerNews stories, bluesky posts: 5,311 stars and zero matched Hacker News stories or Bluesky posts.
  • npm downloadsLast4Weeks, npm downloadsSame4WeeksYearAgo, medianDownloadsRatio: 2.29 times growth versus the 4.1 times catalog baseline.
  • peers DOMPurify and sanitize-html: Both have fewer indexed dependent repositories and faster download growth.
  • nuxt-security.vercel.app/middleware/xss-validator: Nuxt Security uses js-xss in its middleware.
Vouched for4.7

Who stands behind it being good?

Claude Opus 5.5: 3.0, likely 2.0 to 4.5

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, likely 5.2 to 7.5

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.

Safe6.0

How safe is it to depend on?

Claude Opus 5.5: 5.5, likely 4.5 to 7.0

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

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	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

npm downloads, 4 weeks
31M ×2.3 in a year
GitHub stars
5.3k
Commits, 12 months
11
npm version
1.0.17 Oct 2026
Versions, 12 months
2
Advisories, 24 months
0 of 0 ever
OpenSSF Scorecard
5.4 out of 10, Nov 2026
Licence
MIT

Read on 21 November 2026 from GitHub (leizongmin/js-xss), npm (xss), 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