# Web security libraries

Set safe headers, limit request rates and clean the HTML that users send. 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.

| Rank | Project | Overall | Needed by many | Helps a lot | Holds up over time | Used widely | Vouched for | Safe | Best for |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | [DOMPurify](https://elestia.ai/opensource/web-security/dompurify/index.md) | 8.7 | 4.9 | 9.0 | 8.3 | 7.1 | 8.6 | 8.1 | Any app that has to render HTML from users, markdown or third parties without opening an XSS hole, especially in the browser. |
| 2 | [Helmet](https://elestia.ai/opensource/web-security/helmet/index.md) | 8.2 | 5.9 | 8.3 | 7.3 | 7.3 | 7.8 | 8.5 | Express, NestJS or Fastify (via @fastify/helmet) apps that want safe default security headers and a configurable CSP from one line of code. |
| 3 | [express-rate-limit](https://elestia.ai/opensource/web-security/express-rate-limit/index.md) | 7.9 | 4.9 | 7.7 | 8.1 | 6.7 | 6.6 | 8.0 | Express (or Connect-style) apps that want per-client request limits with a few lines of config and an optional Redis store. |
| 4 | [cors](https://elestia.ai/opensource/web-security/cors/index.md) | 7.6 | 5.3 | 7.5 | 6.9 | 8.9 | 7.6 | 8.3 | Express or Connect APIs that a browser front end on another origin must call. |
| 5 | [rate-limiter-flexible](https://elestia.ai/opensource/web-security/rate-limiter-flexible/index.md) | 7.4 | 5.4 | 8.2 | 7.2 | 4.4 | 6.1 | 6.9 | Backend teams that need atomic rate limits shared across servers, a database store other than Redis, or limits outside Express. |
| 6 | [Upstash Ratelimit](https://elestia.ai/opensource/web-security/upstash-ratelimit/index.md) | 7.0 | 4.2 | 7.5 | 7.1 | 5.2 | 6.2 | 7.5 | Teams on Vercel, Cloudflare Workers or other serverless platforms who need shared rate limits without managing a Redis connection. |
| 7 | [sanitize-html](https://elestia.ai/opensource/web-security/sanitize-html/index.md) | 6.8 | 4.4 | 6.9 | 7.1 | 6.7 | 6.2 | 5.6 | Node back ends that must clean user HTML on the server without jsdom, and that need fine control over the tags and attributes they allow and how they are rewritten. |
| 8 | [csrf-csrf](https://elestia.ai/opensource/web-security/csrf-csrf/index.md) | 6.1 | 3.4 | 6.6 | 4.7 | 3.9 | 4.5 | 7.2 | Express apps without server sessions, such as SPA backends, that need a maintained replacement for csurf. |
| 9 | [Arcjet](https://elestia.ai/opensource/web-security/arcjet/index.md) | 5.7 | 4.7 | 6.6 | 6.7 | 2.9 | 4.5 | 6.8 | Teams on Next.js, Vercel or Fly.io that want managed bot protection and rate limiting from one SDK, and are willing to pay for a hosted service. |
| 10 | [js-xss](https://elestia.ai/opensource/web-security/xss/index.md) | 5.0 | 4.3 | 5.5 | 4.7 | 6.0 | 4.7 | 6.0 | Projects that already use it, or that need a tiny HTML filter with a strict whitelist and no DOM, for low-risk content. |

## The numbers

| Project | Downloads, 4 weeks | In a year | GitHub stars | Commits, 12 months | Last npm release | Advisories, 24 months |
| --- | --- | --- | --- | --- | --- | --- |
| DOMPurify | 402M | ×6.9 | 18k | 353 | Nov 2026 | 26 |
| Helmet | 92M | ×4.2 | 11k | 72 | Jul 2026 | 0 |
| express-rate-limit | 388M | ×10 | 3.3k | 136 | Nov 2026 | 1 |
| cors | 499M | ×5.1 | 6.2k | 10 | Jan 2026 | 0 |
| rate-limiter-flexible | 19M | ×3.4 | 3.6k | 123 | Nov 2026 | 0 |
| Upstash Ratelimit | 14M | ×12 | 2.1k | 24 | Nov 2026 | 0 |
| sanitize-html | 73M | ×4.7 | 4.7k | 377 | Nov 2026 | 10 |
| csrf-csrf | 1.1M | ×4.2 | 197 | 3 | Nov 2026 | 0 |
| Arcjet | 40k | ×2.5 | 700 | 648 | Nov 2026 | 0 |
| js-xss | 31M | ×2.3 | 5.3k | 11 | Oct 2026 | 0 |

All categories: https://elestia.ai/opensource/index.md
