Html2Markdown 8.1.2.185-beta

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

HTML2Markdown

Converts HTML to Markdown.


Html2Markdown

Build Status

Branch Status
master master
develop develop

Coverage Quality Gate Status

Support

This project will currently convert the following HTML tags:-

  • <a>
  • <strong>
  • <b>
  • <em>
  • <i>
  • <br>
  • <code>
  • <h1>
  • <h2>
  • <h3>
  • <h4>
  • <h5>
  • <h6>
  • <blockquote>
  • <img>
  • <hr>
  • <p>
  • <pre>
  • <ul>
  • <ol>

The converter preserves the original HTML for <div>, <table>, <iframe>, and <canvas> elements, including their contents. Set ConverterOptions.ConvertTables to convert supported tables to GitHub-Flavoured Markdown instead.

Installing via NuGet

NuGet version

    Install-Package Html2Markdown

Usage

Strings

var html = "Something to <strong>convert</strong>";
var converter = new Converter();
var markdown = converter.Convert(html);

Files

var path = "file.html";
var converter = new Converter();
var markdown = converter.ConvertFile(path);

Custom tags

Register tag renderers when you need to add support for an unsupported tag or replace the default behaviour for a supported tag. Custom renderers receive the current HTML element and a rendering context that can render child nodes through the active renderer set.

using AngleSharp.Dom;
using Html2Markdown;

var options = new ConverterOptions();
options.TagRenderers.Add(new MarkTagRenderer());

var converter = new Converter(options);
var markdown = converter.Convert("<mark>highlighted</mark>");

public sealed class MarkTagRenderer : IHtmlTagRenderer
{
    public string TagName => "mark";

    public string Render(IElement element, HtmlTagRenderingContext context)
    {
        return $"=={context.RenderChildren(element)}==";
    }
}

If a custom renderer uses the same TagName as a built-in renderer, the custom renderer replaces the built-in behaviour for that tag. Tag names are matched case-insensitively, and options are copied when the Converter is constructed.

Tables

Tables are preserved as raw HTML by default. Enable GitHub-Flavoured Markdown table conversion when needed:

var options = new ConverterOptions { ConvertTables = true };
var converter = new Converter(options);
var markdown = converter.Convert("<table><tr><th>Name</th></tr><tr><td>Sam</td></tr></table>");

Enabled conversion creates a GitHub-Flavoured Markdown pipe table. It supports headers, align="left", align="center", and align="right", plus rowspan and colspan; spanned positions are represented by empty Markdown cells. Tables without a header use an empty synthetic header, and captions are emitted after the table. Tables with multiline cell content remain raw HTML because they cannot be represented safely as a Markdown table.

Documentation

Library Documentation

Migrating from version 7

Version 8 is a breaking release. Read the version 7 to 8 migration guide before upgrading.

Try it

This library is showcased at http://html2markdown.bayn.es.

Contributing

For those interested in contributing then please read the guidelines

License

This project is licensed under Apache License 2.0.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (10)

Showing the top 5 NuGet packages that depend on Html2Markdown:

Package Downloads
Terradue.Stars

Stars is a set of services for working with Spatio Temporal Catalog such as STAC but not only

Terradue.Data.Stars

Collection of data Plugins for Terradue.Stars

EPS.Extensions.YamlMarkdown

If you've ever worked on an app and you needed quick access to something that can read a Markdown file with YAML front-matter, then this is your library. Using YamlDotNet and Markdig, we take your YAML object, serialize it for you, and give you Markdown and parsed HTML for your page data.

L.52AbpPro.Blogging.Application

Package Description

SunamoMarkdown

Wrapper around Html2Markdown library

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Html2Markdown:

Repository Stars
rnwood/smtp4dev
smtp4dev - the fake smtp email server for development and testing
Meowv/Blog
🤣本项目有不同开发版本,最新版底层基于 abp vNext 搭建和免费开源跨平台框架 .NET5 进行开发,使用 MongoDB 存储数据,Redis 缓存数据。项目采用前后端分离的模式进行开发,API 遵循 RESTful 接口规范,页面使用 Blazor 进行开发,可作为 .NET Core 入门项目进行学习。If you liked `Blog` project or if it helped you, please give a star ⭐️ for this repository. 👍👍👍
whistyun/Markdown.Avalonia
render markdown with Avalonia UI
Version Downloads Last Updated
8.1.2.195-beta 36 9/4/2026
8.1.2.194-beta 40 9/4/2026
8.1.2.193-beta 35 9/4/2026
8.1.2.192-beta 39 9/4/2026
8.1.2.190-beta 35 9/3/2026
8.1.2.187-beta 46 9/3/2026
8.1.2.186-beta 36 9/3/2026
8.1.2.185-beta 75 9/1/2026
8.1.2.184-beta 58 9/1/2026
8.1.2.183-beta 62 9/1/2026
8.1.2.182-beta 77 9/1/2026
8.1.2.181-beta 78 9/1/2026
8.1.2.180-beta 63 9/1/2026
8.1.2.179-beta 66 9/1/2026
8.1.2.178-beta 67 9/1/2026
8.1.2.177-beta 66 9/1/2026
8.1.2.176-beta 72 9/1/2026
8.0.0.21 69 9/4/2026
7.1.2.175-beta 74 8/31/2026
7.1.2.173-beta 84 8/31/2026
Loading failed