databinding.WebSecurity.HtmlSanitizer
2026.11.18.3
Prefix Reserved
dotnet add package databinding.WebSecurity.HtmlSanitizer --version 2026.11.18.3
NuGet\Install-Package databinding.WebSecurity.HtmlSanitizer -Version 2026.11.18.3
<PackageReference Include="databinding.WebSecurity.HtmlSanitizer" Version="2026.11.18.3" />
<PackageVersion Include="databinding.WebSecurity.HtmlSanitizer" Version="2026.11.18.3" />
<PackageReference Include="databinding.WebSecurity.HtmlSanitizer" />
paket add databinding.WebSecurity.HtmlSanitizer --version 2026.11.18.3
#r "nuget: databinding.WebSecurity.HtmlSanitizer, 2026.11.18.3"
#:package databinding.WebSecurity.HtmlSanitizer@2026.11.18.3
#addin nuget:?package=databinding.WebSecurity.HtmlSanitizer&version=2026.11.18.3
#tool nuget:?package=databinding.WebSecurity.HtmlSanitizer&version=2026.11.18.3
databinding.WebSecurity.HtmlSanitizer
databinding.WebSecurity.HtmlSanitizer is a .NET 8+ library designed to sanitize HTML content by removing potentially harmful tags, attributes, styles, and CSS classes. It ensures that the HTML content adheres to a specified set of allowed elements and attributes, making it safe for use in web applications.
This package is based on Ganss.HtmlSanitizer without backward compatibility to .NET Framework.
Getting started
Prerequisites
- .NET 8 or later
- Visual Studio 2022/Code or later
Installation
To install the library, you can use the NuGet package manager:
dotnet add package databinding.WebSecurity.HtmlSanitizer
Usage
Here's a basic example of how to use it:
using databinding.WebSecurity.HtmlSanitizer;
var options = new HtmlSanitizerOptions
{
AllowedTags = new HashSet { "a", "p", "strong" },
AllowedAttributes = new HashSet { "href", "style" },
AllowedCssProperties = new HashSet { "color" },
UriAttributes = new HashSet { "href" }
};
var sanitizer = new HtmlSanitizer(options);
var sanitizedHtml = sanitizer.Sanitize("<p onclick="alert('xss')">Test</p>");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AngleSharp (>= 1.10.4)
- AngleSharp.Css (>= 1.4.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on databinding.WebSecurity.HtmlSanitizer:
| Package | Downloads |
|---|---|
|
databinding.WebSecurity.HtmlSanitizer.AspNetCore
databinding.WebSecurity.HtmlSanitizer.AspNetCore provides ActionFilter for use in MVC and API applications. These remove HTML from user input to avoid XSS. Only simple HTML tags for rich text editors are allowed. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.11.18.3 | 81 | 11/18/2026 |
| 2026.11.18.2 | 78 | 11/18/2026 |
| 2026.11.11.1 | 132 | 11/11/2026 |
| 2026.10.5.2 | 188 | 10/5/2026 |
| 2026.9.1.1 | 196 | 9/1/2026 |
| 2026.7.22.1 | 264 | 7/22/2026 |
| 2025.7.23.2 | 1,092 | 7/23/2025 |
| 2025.7.23.1 | 666 | 7/23/2025 |
| 2025.7.22.3 | 645 | 7/22/2025 |
| 2025.7.18.3 | 237 | 7/18/2025 |
| 2025.4.28.1 | 299 | 4/28/2025 |
| 2025.4.16.3 | 351 | 4/16/2025 |
| 2025.4.16.1 | 310 | 4/16/2025 |
| 2025.4.14.1 | 331 | 4/14/2025 |
| 2025.4.3.1 | 290 | 4/3/2025 |
| 2025.4.1.1 | 291 | 4/1/2025 |
| 2025.3.26.1 | 597 | 3/26/2025 |
| 2025.3.24.1 | 834 | 3/24/2025 |
| 2025.3.21.1 | 211 | 3/21/2025 |
| 2025.2.18.1 | 215 | 2/18/2025 |