Soenneker.Html.Formatter 11.0.227

Prefix Reserved
dotnet add package Soenneker.Html.Formatter --version 11.0.227
                    
NuGet\Install-Package Soenneker.Html.Formatter -Version 11.0.227
                    
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.Formatter" Version="11.0.227" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Html.Formatter" Version="11.0.227" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Html.Formatter" />
                    
Project file
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.Formatter --version 11.0.227
                    
#r "nuget: Soenneker.Html.Formatter, 11.0.227"
                    
#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.Formatter@11.0.227
                    
#: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.Formatter&version=11.0.227
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Html.Formatter&version=11.0.227
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.227 91 10/29/2026
11.0.226 224 10/27/2026
11.0.225 103 10/26/2026
11.0.223 112 10/26/2026
11.0.222 127 10/26/2026
11.0.221 83 10/26/2026
11.0.220 92 10/26/2026
4.0.218 166 10/25/2026
4.0.217 563 10/15/2026
4.0.216 134 10/15/2026
4.0.215 92 10/14/2026
4.0.214 108 10/14/2026
4.0.212 161 10/14/2026
4.0.211 130 10/14/2026
4.0.204 128 10/12/2026
4.0.202 174 10/12/2026
4.0.201 93 10/12/2026
4.0.199 93 10/12/2026
4.0.198 101 10/12/2026
4.0.197 284 10/12/2026
Loading failed

Update dependency Soenneker.Utils.File to 11.0.2329 (#416)