Soenneker.Extensions.String.Html 4.0.910

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

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
4.0.933 51 9/16/2026
4.0.932 43 9/16/2026
4.0.931 44 9/16/2026
4.0.930 50 9/16/2026
4.0.928 44 9/15/2026
4.0.927 98 9/13/2026
4.0.925 89 9/13/2026
4.0.924 84 9/13/2026
4.0.923 84 9/12/2026
4.0.922 80 9/12/2026
4.0.921 86 9/12/2026
4.0.920 86 9/12/2026
4.0.919 84 9/12/2026
4.0.917 81 9/12/2026
4.0.915 92 9/12/2026
4.0.914 92 9/11/2026
4.0.913 98 9/9/2026
4.0.912 91 9/9/2026
4.0.911 88 9/9/2026
4.0.910 106 9/8/2026
Loading failed

Updated Multiple NuGet packages