CDS.Markdown is a comprehensive .NET library for both rendering and generating Markdown. It is designed for easy integration into your .NET 8 and .NET 10 applications.
CDS.Markdown.Lite |
CDS.Markdown |
|
|---|---|---|
| Gives you | MarkdownTextBox + the Fluent/Builder generation APIs |
Everything in CDS.Markdown.Lite, plus MarkdownViewer |
| Depends on | Markdig only |
Markdig, Microsoft.Web.WebView2, and CDS.Markdown.Lite |
| Pick this when | You only need prose-sized rendering or Markdown generation, and want to keep WebView2 out of your dependency tree entirely | You need MarkdownViewer's full document fidelity (Mermaid, MathJax, real tables, images, links) |
CDS.Markdown depends on CDS.Markdown.Lite, so installing CDS.Markdown still gets you MarkdownTextBox and the generation APIs too — nothing is lost by installing the bigger package. Install CDS.Markdown.Lite on its own only when you specifically want to avoid the WebView2 dependency.
- 🖥️ WinForms Viewer Control (
CDS.Markdown): A drop-inMarkdownViewercontrol powered by WebView2 and Markdig. Includes Light and Dark mode theme support. - ⚡ Lightweight Text Box Control (
CDS.Markdown.Lite):MarkdownTextBox, aRichTextBox-based control for prose-sized Markdown (headings, formatting, lists, tables) with no WebView2 process and a synchronous preferred-height read — a cheaper option when you're rendering many small fragments (e.g. chat bubbles) rather than a full document. - 📝 Programmatic Creation (
CDS.Markdown.Lite): Generate Markdown dynamically using a clean Fluent API or a traditional Builder API. - 🔌 Offline-First: Embedded resources for GitHub-style CSS, Mermaid.js diagrams, and MathJax (LaTeX math) mean no internet connection is required to render advanced Markdown.
- 🧪 Fully Tested: Comprehensive unit test coverage ensuring reliable HTML generation and Markdown building.
Install whichever package matches what you need (see the table above):
dotnet add package CDS.Markdown.Lite
# or, for the full WebView2 viewer too:
dotnet add package CDS.MarkdownDrop the MarkdownViewer control onto your form and load a file:
await markdownViewer1.LoadMarkdownAsync("readme.md");👉 Read the full Viewer Documentation
Or, for many small fragments rather than a full document, drop a MarkdownTextBox control onto your form instead — this one only needs CDS.Markdown.Lite:
markdownTextBox1.SetMarkdown("**Hello**, world!");See the "Embedding as a Fragment" section of the Viewer Documentation for the tradeoff between the two controls.
Create structured Markdown programmatically without string wrangling:
var markdown = new FluentMarkdownDocument()
.AddHeading("Hello, World!")
.AddParagraph("This is a **bold** statement.")
.AddBulletList(["First item", "Second item"])
.AddMermaidDiagram("graph TD;\nA-->B;")
.ToMarkdown();👉 Read the full Creation Documentation
CDS.Markdown.Lite: The lightweight library —MarkdownTextBoxand the Markdown generation APIs. Depends on Markdig only.CDS.Markdown: The WebView2-based viewer control and its HTML-building pipeline. Depends onCDS.Markdown.Lite.Demo: A sample WinForms application demonstrating the viewer, the text box, and the creation APIs.UnitTests: MSTest project covering both packages — HTML rendering, session management,MarkdownTextBoxrendering, and Markdown generation.UiTests: FlaUI project that drives the realDemo.exeend-to-end.
- github-markdown-css (MIT License)
- Markdig (BSD-2-Clause)
- Mermaid.js (MIT License)
- MathJax (Apache-2.0)