# mganss/HtmlSanitizer

Cleans HTML to avoid XSS attacks

Repository: https://github.com/mganss/HtmlSanitizer
Canonical: https://ross.abutalabs.com/products/htmlsanitizer
Language: C#
License: MIT
License Family: permissive
Topics: xss, html, sanitizer
Last push: 2026-08-26T15:29:42+00:00

## Health v2 (maintenance only)
Score: 98/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 99, release rhythm 97, longevity 100
- inputs: {"age_days": 4817, "days_push": 7, "days_rel": 23, "gap_med": 7, "n_releases_24m": 12}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1707, forks 231 (observed 2026-08-28T04:05:24.993594+00:00)

## What it is
A .NET library for cleaning HTML fragments and documents of constructs that can lead to XSS attacks, built on the AngleSharp parser. It is highly configurable, allowing control over allowed tags, attributes, CSS properties, and URI schemes.

## Use cases
- sanitize user-submitted HTML to prevent XSS
- clean HTML fragments before rendering in a web app
- strip dangerous tags and attributes from rich text input
- allow only whitelisted HTML tags and CSS properties
- protect against tag poisoning from malformed HTML
- sanitize HTML in ASP.NET applications

## When to choose
- you need a robust, parser-based HTML sanitizer in .NET
- you need fine-grained control over allowed tags, attributes, CSS, and URI schemes
- you want protection against malformed HTML corrupting document structure

## When to avoid
- your project is not on the .NET platform
- you only need to escape plain text rather than sanitize rich HTML
- you need a browser-side JavaScript sanitizer

## Facets
- artifact type: library
- maturity: active
- function: security, parser, templating
- domain: security, web-development, backend
- platform: dotnet, cross-platform
- tags: xss, html-sanitizer, html-parsing, css-sanitization, anglesharp

## Member repositories
- mganss/HtmlSanitizer (main) score 98

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:24.993594+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:37:27.332703+00:00, confidence not recorded.
  - readme: https://github.com/mganss/HtmlSanitizer (fetched 2026-08-28T04:05:24.993594+00:00, sha e5c0f4028d92)
- Data as of 2026-08-30T08:39:29.467469+00:00.
