Soenneker.Html.Formatter
4.0.134
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Html.Formatter --version 4.0.134
NuGet\Install-Package Soenneker.Html.Formatter -Version 4.0.134
<PackageReference Include="Soenneker.Html.Formatter" Version="4.0.134" />
<PackageVersion Include="Soenneker.Html.Formatter" Version="4.0.134" />
<PackageReference Include="Soenneker.Html.Formatter" />
paket add Soenneker.Html.Formatter --version 4.0.134
#r "nuget: Soenneker.Html.Formatter, 4.0.134"
#:package Soenneker.Html.Formatter@4.0.134
#addin nuget:?package=Soenneker.Html.Formatter&version=4.0.134
#tool nuget:?package=Soenneker.Html.Formatter&version=4.0.134
Soenneker.Html.Formatter
Formats HTML strings, files, and directories with AngleSharp.
Install
dotnet add package Soenneker.Html.Formatter
Register
using Soenneker.Html.Formatter.Registrars;
services.AddHtmlFormatterAsSingleton();
A scoped registration is also available through AddHtmlFormatterAsScoped().
Format strings
using Soenneker.Html.Formatter.Abstract;
string readable = await formatter.PrettyPrint(
"<main><h1>Account</h1><p>Ready</p></main>",
cancellationToken);
string compact = await formatter.Normalize(readable, cancellationToken);
Both methods parse and serialize the input rather than only changing whitespace. AngleSharp may repair malformed markup, normalize element or attribute syntax, and supply document structure when the input represents a full document. A null, empty, or whitespace-only string produces an empty string.
Format files
string preview = await formatter.PrettyPrintFile("page.html", cancellationToken: cancellationToken);
await formatter.SavePrettyPrintedFile(
sourcePath: "page.html",
destinationPath: "output/page.html",
cancellationToken: cancellationToken);
await formatter.SaveNormalizedFile(
sourcePath: "page.html",
cancellationToken: cancellationToken); // overwrites page.html
The methods ending in File return formatted content without changing the source. The methods beginning with Save write to destinationPath, or overwrite the source when no destination is supplied.
Format a directory
await formatter.PrettyPrintDirectory(
"templates",
recursive: true,
cancellationToken: cancellationToken);
This overwrites .html and .htm files in place. With recursive: false, only files directly inside the specified directory are processed. Cancellation does not roll back files already written.
| 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. |
-
net10.0
- Soenneker.AngleSharp.Parser (>= 4.0.62)
- Soenneker.Utils.Directory (>= 4.0.916)
- Soenneker.Utils.File (>= 4.0.2246)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Html.Formatter:
| Package | Downloads |
|---|---|
|
Soenneker.Playwrights.Crawler
A configurable Playwright crawler with rich stealth and control options. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.147 | 0 | 9/5/2026 |
| 4.0.146 | 0 | 9/5/2026 |
| 4.0.145 | 0 | 9/5/2026 |
| 4.0.144 | 23 | 9/4/2026 |
| 4.0.143 | 34 | 9/4/2026 |
| 4.0.142 | 30 | 9/4/2026 |
| 4.0.141 | 67 | 9/4/2026 |
| 4.0.140 | 59 | 9/4/2026 |
| 4.0.137 | 70 | 9/4/2026 |
| 4.0.136 | 78 | 9/4/2026 |
| 4.0.135 | 36 | 9/4/2026 |
| 4.0.134 | 231 | 9/1/2026 |
| 4.0.133 | 100 | 8/31/2026 |
| 4.0.132 | 74 | 8/31/2026 |
| 4.0.131 | 104 | 8/31/2026 |
| 4.0.130 | 197 | 8/30/2026 |
| 4.0.129 | 81 | 8/30/2026 |
| 4.0.128 | 134 | 8/30/2026 |
| 4.0.127 | 167 | 8/29/2026 |
| 4.0.126 | 83 | 8/29/2026 |