Soenneker.Extensions.String.Html 11.0.1037

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.String.Html --version 11.0.1037
                    
NuGet\Install-Package Soenneker.Extensions.String.Html -Version 11.0.1037
                    
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.Extensions.String.Html" Version="11.0.1037" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.String.Html" Version="11.0.1037" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.String.Html" />
                    
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.Extensions.String.Html --version 11.0.1037
                    
#r "nuget: Soenneker.Extensions.String.Html, 11.0.1037"
                    
#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.Extensions.String.Html@11.0.1037
                    
#: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.Extensions.String.Html&version=11.0.1037
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.String.Html&version=11.0.1037
                    
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.Extensions.String.Html

Parse HTML strings to format or minify markup, extract text, convert common elements to Markdown, and find elements.

Installation

dotnet add package Soenneker.Extensions.String.Html

Convert HTML to Markdown

using Soenneker.Extensions.String.Html;

string html = "<h2>Status</h2><p>Build <strong>passed</strong>.</p>";
string? markdown = await html.ToMarkdownFromHtml();

The converter handles paragraphs, headings, emphasis, links, ordered and unordered lists, block quotes, inline code, preformatted blocks, and line breaks. Other elements contribute their child content. Whitespace is normalized, so this is intended for readable Markdown rather than lossless round-tripping.

Link destinations are copied as written. The method is not an HTML sanitizer or a Markdown-security boundary; sanitize untrusted markup and validate links before rendering the result as active content.

Format or minify markup

string? formatted = await html.FormatAsHtml();
string? compact = await html.MinifyHtml();

Both methods parse with AngleSharp and serialize the resulting document. Parsing can repair malformed markup and can add document structure such as html, head, and body; the output is not guaranteed to preserve the input byte-for-byte. Formatting changes layout, while minification uses AngleSharp's compact formatter.

Null and whitespace inputs are returned unchanged. Text that does not pass the package's lightweight HTML sniff is also returned unchanged.

Extract text

string? text = await "<p>Hello <b>world</b></p>".StripTagsFromHtml();
// "Hello world"

StripTagsFromHtml() returns the parsed body element's trimmed TextContent. This removes markup but is not sanitization, and text inside elements such as script or style may still be present. For non-HTML input it returns Trim() of the original text.

Detect content and elements

bool containsMarkup = html.ContainsHtml();
bool hasHeading = await html.HasHtmlElement("h2");

ContainsHtml() is a syntax sniff, not validation. HasHtmlElement() first performs an allocation-free opening-tag check, then parses the document and compares actual element names case-insensitively. It returns false for null/whitespace HTML or tag names.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1043 52 12/3/2026
11.0.1042 58 12/3/2026
11.0.1041 58 12/3/2026
11.0.1040 52 12/3/2026
11.0.1039 51 12/2/2026
11.0.1038 54 12/2/2026
11.0.1037 53 12/2/2026
11.0.1036 55 12/2/2026
11.0.1035 54 12/2/2026
11.0.1034 52 12/2/2026
11.0.1033 59 12/2/2026
11.0.1032 55 12/2/2026
11.0.1031 62 12/2/2026
11.0.1030 58 12/1/2026
11.0.1029 57 12/1/2026
11.0.1028 55 12/1/2026
11.0.1027 54 12/1/2026
11.0.1026 56 12/1/2026
11.0.1025 57 12/1/2026
11.0.1024 56 12/1/2026
Loading failed

Updated Multiple NuGet packages