Meziantou.Framework.HtmlToMarkdown 2.0.0

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

Meziantou.Framework.HtmlToMarkdown

A .NET library to convert HTML fragments to Markdown.

Usage

Basic conversion

using Meziantou.Framework;

var html = "<h1>Title</h1><p>Hello <strong>world</strong></p>";
var markdown = HtmlToMarkdown.Convert(html);

// # Title
//
// Hello **world**

Configure conversion options

using Meziantou.Framework;

var html = "<h1>Title</h1><p>Line 1<br>Line 2</p>";

var markdown = HtmlToMarkdown.Convert(html, new HtmlToMarkdownOptions
{
    HeadingStyle = HeadingStyle.Setext,
    EmphasisMarker = EmphasisMarker.Underscore,
    CodeBlockStyle = CodeBlockStyle.Fenced,
    CodeBlockFenceCharacter = '~',
    UnorderedListMarker = '*',
    ThematicBreak = "***",
    LineBreakStyle = LineBreakStyle.Backslash,
    UseSimplePunctuation = true,
    EmojiShortcodeMode = EmojiShortcodeMode.GitHub,
    UnknownElementHandling = UnknownElementHandling.StripKeepContent,
});

Replace SmartyPants punctuation with simple ASCII

You can opt in to convert smart punctuation in regular text nodes:

var markdown = HtmlToMarkdown.Convert(
    "<p>“Hello” ‘Hello’ — – … « »</p>",
    new HtmlToMarkdownOptions { UseSimplePunctuation = true });

// "Hello" 'Hello' \-\-\- \-\- ... \<\< \>\>

Emoji shortcode replacement

var markdown = HtmlToMarkdown.Convert("<p>I ❤️ Markdown</p>", new HtmlToMarkdownOptions
{
    EmojiShortcodeMode = EmojiShortcodeMode.GitHub, // => I :heart: Markdown
});

var unicodeMarkdown = HtmlToMarkdown.Convert("<p>I ❤️ Markdown</p>", new HtmlToMarkdownOptions
{
    EmojiShortcodeMode = EmojiShortcodeMode.Unicode, // => I :red_heart: Markdown
});

Supported HTML elements

The converter supports common Markdown-related elements, including:

  • Headings (h1-h6)
  • Paragraphs and line breaks (p, br)
  • Emphasis (strong, b, em, i, del, s, strike)
  • Links and images (a, img)
  • Lists (ul, ol, li) including task list checkboxes (input type="checkbox")
  • Blockquotes (blockquote)
  • Code (code, pre) with fenced or indented blocks
  • Tables (table, thead, tbody, tfoot, tr, th, td) with alignment support
  • Definition lists (dl, dt, dd)

script, style, and noscript elements are stripped.

Unknown elements are handled using UnknownElementHandling:

  • PassThrough (default): keep raw HTML
  • Strip: remove the element and its content
  • StripKeepContent: remove the element but keep converted child content
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.  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
2.0.12 60 10/21/2026
2.0.11 86 10/16/2026
2.0.10 131 10/5/2026
2.0.9 111 9/27/2026
2.0.8 130 9/11/2026
2.0.7 124 9/9/2026
2.0.6 128 9/6/2026
2.0.5 122 9/3/2026
2.0.4 137 8/23/2026
2.0.3 133 8/16/2026
2.0.2 116 8/16/2026
2.0.1 138 8/9/2026
2.0.0 305 7/5/2026
1.0.6 154 6/28/2026
1.0.5 150 6/13/2026
1.0.4 139 5/31/2026
1.0.3 179 5/23/2026
1.0.2 401 4/12/2026
1.0.1 145 4/8/2026
1.0.0 169 4/4/2026