Soenneker.Html.Normalizer
4.0.12
Prefix Reserved
dotnet add package Soenneker.Html.Normalizer --version 4.0.12
NuGet\Install-Package Soenneker.Html.Normalizer -Version 4.0.12
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Html.Normalizer" Version="4.0.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Html.Normalizer" Version="4.0.12" />
<PackageReference Include="Soenneker.Html.Normalizer" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Html.Normalizer --version 4.0.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Html.Normalizer, 4.0.12"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Html.Normalizer@4.0.12
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Html.Normalizer&version=4.0.12
#tool nuget:?package=Soenneker.Html.Normalizer&version=4.0.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Soenneker.Html.Normalizer
Deterministic, configurable HTML normalization for hashing and change detection
Installation
dotnet add package Soenneker.Html.Normalizer
Usage
using Soenneker.Html.Normalizer.Models;
HtmlNormalizationResult result = await normalizer.NormalizeAndHash(renderedHtml);
Console.WriteLine(result.Html);
Console.WriteLine(result.Hash);
The default profile removes common runtime artifacts while preserving indexable content:
- HTML comments
<style>elements- scripts other than
application/ld+json nonceattributes- Blazor
_bl_*element-reference attributes - element IDs and common HTML/ARIA attributes that reference them
- formatting-only inter-element whitespace
It also normalizes line endings and sorts ordinary HTML attributes. Hashing uses XXH3 through
Soenneker.Hashing.XxHash, producing a lowercase 64-bit hexadecimal hash for fast,
non-adversarial change detection.
Application-specific normalization
using System.Text.RegularExpressions;
using Soenneker.Html.Normalizer.Options;
var options = new HtmlNormalizationOptions();
options.RemoveSelectors.Add("[data-runtime-only]");
options.RemoveAttributes.Add("data-request-id");
options.Replacements.Add(new HtmlNormalizationReplacement(
"session-[a-f0-9]{32}",
"session-id",
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant));
string normalized = await normalizer.Normalize(renderedHtml, options);
Dependency injection
using Soenneker.Html.Normalizer.Registrars;
services.AddHtmlNormalizerAsSingleton();
// or services.AddHtmlNormalizerAsScoped();
Browser readiness is intentionally outside this package. Wait for hydration or another application-specific readiness signal before capturing and normalizing rendered HTML.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Soenneker.AngleSharp.Parser (>= 4.0.37)
- Soenneker.Extensions.Task (>= 4.0.124)
- Soenneker.Extensions.ValueTask (>= 4.0.117)
- Soenneker.Hashing.XxHash (>= 4.0.67)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.