Soenneker.Html.Formatter 4.0.146

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

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
Loading failed