ReverseMarkdown is a HTML to Markdown converter library in C#. v6 uses AngleSharp's HTML5-compliant parser and a Markdown DOM pipeline for reliable, performant conversion.
📖 Full documentation: mysticmind.github.io/reversemarkdown-net
Using v5.x? See the v5.x documentation.
If you have used and benefitted from this library. Please feel free to sponsor me!
dotnet add package ReverseMarkdownvar converter = new ReverseMarkdown.Converter();
string html = "This a sample <strong>paragraph</strong> from <a href=\"http://test.com\">my site</a>";
string result = converter.Convert(html);
// This a sample **paragraph** from [my site](http://test.com)With configuration and a flavor:
var config = new ReverseMarkdown.Config
{
Flavor = MarkdownFlavor.GitHub,
Formatting = { RemoveComments = true },
Links = { SmartHref = true },
};
var converter = new ReverseMarkdown.Converter(config);- Seven output flavors - Default, GitHub, CommonMark, Slack, Telegram, MultiMarkdown, and Pandoc, selected via the
Flavorenum. - Spec-compliant round-trips - CommonMark and GitHub Flavored Markdown round-trip at 100% against canonical cmark-gfm; MultiMarkdown and Pandoc verified against canonical pandoc.
- Extensible - custom readers (
IMdReader+[MarkdownReader]), tag aliases, and aParse/RenderMarkdown DOM for direct transformation. - Tables, links, and images - nested tables and captions, smart href handling, URI-scheme whitelisting, and base64 image handling (include / skip / save to disk).
- Broad framework support - targets
netstandard2.0,net8.0,net9.0, andnet10.0(runs on .NET Framework 4.6.1+, .NET Core 2.0+, Mono, and Unity). - Trimming and Native AOT ready - the default conversion path uses no reflection; add custom readers with
RegisterReaderunder trimming/AOT. See Supported Frameworks.
v6 replaces the v5 HtmlAgilityPack engine with an AngleSharp HTML5 parser feeding a Markdown DOM and per-flavor writers. It is roughly 2–2.6× faster than v5 and allocates about 2.7× less memory.
Measured with BenchmarkDotNet on .NET 9.0 (Apple M1), comparing published ReverseMarkdown 5.5.0
vs 6.0.0 on the same inputs (lower is better):
| Fixture | Mean time v5 → v6 | Allocated v5 → v6 |
|---|---|---|
| 1000 paragraphs | 13.7 → 5.2 ms (2.6× faster) | 21 → 7 MB (2.8× less) |
| 10k paragraphs | 119.1 → 63.1 ms (1.9× faster) | 183 → 67 MB (2.7× less) |
| huge.html | 540.6 → 244.3 ms (2.2× faster) | 779 → 288 MB (2.7× less) |
See the Performance guide for details and how to reproduce the benchmark.
The full guide lives at mysticmind.github.io/reversemarkdown-net:
- Getting Started
- Performance
- Flavors
- Configuration reference
- Extending (custom readers, recipes)
- Migrating from v5
This library's initial implementation ideas from the Ruby based Html to Markdown converter xijo/reverse_markdown.
Copyright © Babu Annamalai
ReverseMarkdown is licensed under the MIT License.

