Fast, low-allocation rendering with a normalized design language, themeable CSS variables, and allowlist SVG sanitization — no JavaScript runtime, no headless browser, no subprocess.
string svg = MermaidRenderer.RenderSvg(""" flowchart LR A[Parse] --> B[Layout] B --> C[Render SVG] """); // drop svg directly into your HTML
// what you get
Mermaider parses Mermaid diagram syntax and renders it directly to SVG in-process — no interop, no spawned process, no browser dependency.
Built entirely in C#. No JS runtime dependency, no Puppeteer, no Node subprocess. Ships as a NuGet package that targets net8.0+.
Flowchart, sequence, class, ER, state, architecture, C4, gitgraph, gantt, pie, mindmap, and more — the full Mermaid feature surface.
ObjectPool<StringBuilder> for SVG assembly,
ReadOnlySpan<char> throughout the text pipeline,
SIMD character lookups via SearchValues<char>.
Every SVG output passes through an allowlist sanitizer before leaving the library. Strict mode strips all diagram-source styling, eliminating the injection surface entirely.
Colors are CSS custom properties — override --bg, --fg,
--accent to match any design system. Themes are computed at render time,
no post-processing needed.
All regex patterns are source-generated with [GeneratedRegex].
No reflection-based dispatch. Trims cleanly and publishes as a native binary.
// why mermaider
Mermaider exists because every other option either requires a JavaScript runtime or produces inconsistent output across diagram types. These four properties are non-negotiable.
Every diagram type — flowchart, sequence, class, ER, architecture, gantt, pie, and all
the rest — renders using the same CSS custom-property token system. Set --bg,
--fg, and --accent once; every diagram adapts. No per-type
theme overrides, no inconsistent defaults slipping through.
Every SVG output passes through an allowlist sanitizer before it reaches the caller — no opt-in required. Strict mode removes all diagram-source styling from the stylesheet, so untrusted diagram authors cannot override your design system. Resource limits with a cooperative render deadline bound CPU and memory for arbitrary inputs. All regex patterns carry a 2-second timeout for ReDoS protection.
security docs →
The SVG renderer pools StringBuilder instances via
ObjectPool<StringBuilder> and never allocates one per render.
The text pipeline operates on ReadOnlySpan<char> throughout;
character-class lookups use SearchValues<char> for SIMD acceleration.
Immutable lookup tables are FrozenDictionary. A 6-node flowchart completes
in 3.4 µs and allocates 16 KB — 73× faster than MSAGL, 35× fewer allocations.
Mermaider ships a complete, zero-dependency Sugiyama implementation: cycle removal,
longest-path layering, barycenter crossing minimization, coordinate assignment, and
rectilinear edge routing with rounded corners and shared trunk segments. All three
historically O(N³) phases were rewritten using a CSR adjacency index and now run in
O(V+E). The engine is also published as a standalone Sugiyama NuGet package.
// diagram types
Pass any Mermaid syntax string, get back a complete inline-embeddable SVG. All diagram types share the same themeable CSS variable system. Click any to enlarge.
// quick start
One NuGet reference. No configuration files, no external processes, no runtime setup.
One call to RenderSvg, one SVG string back.
dotnet add package Mermaider — targets net8.0 and later.
No transitive JS or native dependencies.
Construct a MermaidRenderer, optionally passing
RenderOptions to configure colors, strict mode, or resource limits.
The renderer is thread-safe and designed to be shared.
The returned string is a complete, sanitized SVG. Write it directly into your HTML response — no file system, no temp files, no process to clean up.
using Mermaider; string svg = MermaidRenderer.RenderSvg(""" graph TD A[Start] --> B{Check} B --> |yes| C[Done] B --> |no| D[Retry] """); // embed it directly in HTML Response.Write(svg);
var options = new RenderOptions { Bg = "#0D1117", Fg = "#E6EDF3", Strict = new StrictStylingOptions() }; string svg = MermaidRenderer.RenderSvg(diagram, options);
No runtime, no subprocess. Just a NuGet package that turns Mermaid syntax into production-ready SVG.