Soenneker.Html.Formatter 11.0.259

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Html.Formatter --version 11.0.259
                    
NuGet\Install-Package Soenneker.Html.Formatter -Version 11.0.259
                    
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.259" />
                    
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.259" />
                    
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.259
                    
#r "nuget: Soenneker.Html.Formatter, 11.0.259"
                    
#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.259
                    
#: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.259
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Html.Formatter&version=11.0.259
                    
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.262 45 11/19/2026
11.0.260 46 11/18/2026
11.0.259 73 11/18/2026
11.0.257 83 11/18/2026
11.0.256 81 11/18/2026
11.0.255 131 11/17/2026
11.0.254 124 11/15/2026
11.0.253 91 11/15/2026
11.0.252 80 11/15/2026
11.0.251 116 11/14/2026
11.0.250 214 11/12/2026
11.0.249 128 11/11/2026
11.0.248 116 11/11/2026
11.0.247 108 11/11/2026
11.0.244 154 11/11/2026
11.0.243 95 11/11/2026
11.0.242 88 11/11/2026
11.0.241 117 11/11/2026
11.0.240 87 11/11/2026
11.0.239 120 11/11/2026
Loading failed

Updated Soenneker.Utils.File to 11.0.2346