Mermaid diagrams in .NET
ChartForgeX.Mermaid parses Mermaid source and renders it through the native ChartForgeX engine, with no browser, no Node.js and no mermaid-cli.
- Families rendered
- 33
- Atlas themes
- 2
- Browsers needed
- 0
---
title: Dashboard sign-in
---
sequenceDiagram
autonumber
actor User
participant App
participant IdP as Identity provider
participant API
User->>App: Open dashboard
App->>IdP: Authorization request
IdP-->>App: ID token + access token
App->>API: GET /reports (Bearer token)
alt token valid
API-->>App: 200 report data
else token expired
API-->>App: 401 Unauthorized
end
Note over App,API: Tokens refresh silently before expiry
App-->>User: Render chartsFamily atlas
Every diagram below is drawn by ChartForgeX from the source shown with it. Syntax support does not mean the same layout or pixels as Mermaid's browser renderer. Each diagram is drawn by ChartForgeX with your theme, and diagnostics tell you when source is kept without an exact visual interpretation.
Flows and structure 13
Flowchart
Steps, decisions and branches in a process.
Edit in playgroundSource 10 lines
Mermaidflowchart.mmd --- title: Incident response --- flowchart TD alert([Alert raised]) --> triage{Known issue?} triage -->|yes| runbook[Run the runbook] triage -->|no| owner[Page the<br/>service owner] runbook --> verify[Verify recovery] owner --> fix[Ship a fix] fix --> verifySequence
Messages between participants, in the order they happen.
Edit in playgroundSource 20 lines
Mermaidsequence.mmd --- title: Dashboard sign-in --- sequenceDiagram autonumber actor User participant App participant IdP as Identity provider participant API User->>App: Open dashboard App->>IdP: Authorization request IdP-->>App: ID token + access token App->>API: GET /reports (Bearer token) alt token valid API-->>App: 200 report data else token expired API-->>App: 401 Unauthorized end Note over App,API: Tokens refresh silently before expiry App-->>User: Render chartsClass
Types, their members and how they relate.
Edit in playgroundSource 18 lines
Mermaidclass.mmd --- title: Chart model --- classDiagram class Chart { +string Title +WithSize(width, height) +ToSvg() string } class ChartSeries { +string Name +ChartPoint[] Points } class VisualTheme { +VisualTypography Typography } Chart "1" *-- "many" ChartSeries : contains Chart --> VisualTheme : usesState
Composite states, concurrent regions, notes and safe named or direct paints.
Edit in playgroundSource 15 lines
Mermaidstate.mmd --- title: Document review --- stateDiagram-v2 direction LR classDef marked fill:#fef9c3,stroke:#92400e,color:#78350f Ready --> Review:::marked: submit class Ready marked style Review fill:#dbeafe,color:#1e3a8a state Processing { direction TB InnerReady --> InnerDone: finish } Review --> Processing: accept Processing --> Done: completeEntity relationship
Entities, their attributes and the cardinality between them.
Edit in playgroundSource 17 lines
Mermaider.mmd --- title: Orders schema --- erDiagram CUSTOMER ||--o{ ORDER : places ORDER ||--|{ LINE_ITEM : contains PRODUCT ||--o{ LINE_ITEM : "ordered in" CUSTOMER { string id PK string name string email } ORDER { string id PK string customerId FK date placed }Requirement
Requirements and the elements that satisfy or verify them.
Edit in playgroundSource 28 lines
Mermaidrequirement.mmd --- title: Sign-in requirements --- requirementDiagram direction LR functionalRequirement mfa_req { id: "SEC-1" text: Every account signs in with a strong method. risk: High verifymethod: Test } performanceRequirement report_req { id: "OPS-4" text: The weekly report renders in under a second. risk: Low verifymethod: Analysis } element auth_service { type: service docref: "Identity provider" } element report_job { type: job docref: "ChartForgeX report" } auth_service - satisfies -> mfa_req report_job - verifies -> mfa_req report_job - satisfies -> report_reqArchitecture
Services, groups and connections on a system map.
Edit in playgroundSource 16 lines
Mermaidarchitecture.mmd --- title: Report platform --- architecture-beta group edge(cloud)[Edge] group core(cloud)[Platform] group data(database)[Data] in core service web(internet)[Web] in edge service api(server)[API] in core service renderer(server)[Renderer] in core service sql(database)[SQL] in data service blob(disk)[Cache] in data web:R --> L:api api:R --> L:renderer renderer:B --> T:blob api:B --> T:sqlC4
People, systems, nested boundaries and ordered relationships.
Edit in playgroundSource 13 lines
Mermaidc4.mmd C4Container title Checkout platform Person(customer, "Customer", "Places an order") Enterprise_Boundary(company, "Company") { System_Boundary(shop, "Store") { Container(web, "Web app", "Browser", "Browse products and complete checkout") Container(api, "Order service", ".NET", "Validate orders and coordinate payment") ContainerDb(db, "Orders", "SQL", "Store orders and their fulfilment state") } } Rel(customer, web, "Places an order") Rel(web, api, "Submits checkout", "HTTPS") Rel(api, db, "Stores the order")Block
Blocks placed on a column grid, joined by links.
Edit in playgroundSource 12 lines
Mermaidblock.mmd --- title: Render pipeline --- block-beta columns 3 collect["Collect"] model["Typed model"] render["Render"] space:2 svg["SVG"] space:2 png["PNG"] collect --> model model --> render render --> svg render --> pngPacket
Bit ranges of a protocol header, row by row.
Edit in playgroundSource 8 lines
Mermaidpacket.mmd --- title: TCP header --- packet-beta 0-15: "Source Port" 16-31: "Destination Port" 32-63: "Sequence Number" +32: "Acknowledgment Number"Agentflow
Nested agent flows with inert connector and metadata facts.
Edit in playgroundSource 33 lines
Mermaidagentflow.mmd --- title: Review workflow --- agentflow-beta LR connector store["Object store"] store@{ endpoint: "https://example.invalid/data", protocol: http } global shared["Policy guide"]@{ shape: refdoc } end flow team["Review team"] brief["Request"]@{ shape: input } flow worker["Worker"] read["Read input"]@{ shape: tool connectorRef: store.read policy: retries: 2 enabled: true tags: [safe, deterministic] constructor: ignored instruction: "Display data, never execute it." } gate["Ready?"]@{ shape: decision } read edge1@--> gate gate -- no --> read read -.- shared end worker@{ view: collapsed } publish["Publish"]@{ shape: action } brief --> read gate --x publish end edge1@{ instruction: "Only after validation" }ZenUML
Code-like calls and control fragments drawn by the native sequence owner.
Edit in playgroundSource 41 lines
Mermaidzenuml.mmd zenuml title Checkout occurrences group "Application" { @Actor User @Control Service } @Database Store @Queue Bus @Starter(User) // Accept the request Service.checkout(order) { if (valid && !cancelled) { String receipt = new Receipt(order) { Store.save(order) return saved } } else { return declined } loop (retries < 3) { Store.retry(order) } par { Bus: ready(order) } critical (commitLock) { Store.commit() } opt (notify) { Bus: notify(order) } try { Store.flush() } catch (StorageError error) { Store.recover(error) } finally { Store.close() } return accepted } Service --> User: confirmedRailroad
Symbolic grammar rules and choices; bounded IR, EBNF, ABNF and PEG frontends.
Edit in playgroundSource 5 lines
Mermaidrailroad.mmd railroad-beta title "Expression grammar" expression = sequence(nonterminal("term"), zeroOrMore(sequence(choice(terminal("+"), terminal("-")), nonterminal("term")))) ; term = sequence(optional(terminal("-")), oneOrMore(nonterminal("digit"))) ; digit = choice(terminal("0"), terminal("1"), special("another decimal digit")) ;
Planning and process 8
Gantt
Tasks, dependencies and milestones on a calendar.
Edit in playgroundSource 11 lines
Mermaidgantt.mmd gantt title Release train dateFormat YYYY-MM-DD section Engine Layout pass :done, l1, 2026-09-01, 12d Label placement :active, l2, after l1, 10d section Surfaces PNG parity : s1, 2026-09-10, 14d Email preview : s2, after s1, 7d section Release Ship 2.0 :milestone, m1, after l2 s2, 0dTimeline
Ordered events in authored periods and sections, without invented calendar durations.
Edit in playgroundSource 9 lines
Mermaidtimeline.mmd timeline title Delivery history section Discovery Before launch: Interview users : Review findings section Delivery Launch: Ship product<br>and docs : Invite users section Discovery After launch: Learn and improveJourney
Task scores, actors and repeated authored sections.
Edit in playgroundSource 8 lines
Mermaidjourney.mmd journey title Support journey section Contact Open ticket: 2: Customer, Agent section Resolve Diagnose: 4: Agent section Contact Confirm recovery: 5: Customer, AgentKanban
Work items in board columns, with optional metadata.
Edit in playgroundSource 11 lines
Mermaidkanban.mmd --- title: Playground launch --- kanban todo[To do] docs[Write playground docs] share[Share links] doing[In progress] engine[WebAssembly engine]@{ priority: "High" } done[Done] site[chartforgex.com]Git graph
Commits, branches, merges and tags.
Edit in playgroundSource 12 lines
Mermaidgitgraph.mmd --- title: Release 2.0 branch --- gitGraph commit id: "init" branch feature checkout feature commit id: "renderer" commit id: "tests" checkout main commit id: "docs" merge feature id: "merge" tag: "v2.0"Swimlane
A process split into lanes by who owns each step.
Edit in playgroundSource 15 lines
Mermaidswimlane.mmd --- title: Pull request flow --- swimlane-beta LR subgraph Author A[Write source] --> B[Open pull request] end subgraph Build C{Checks pass?} --> D[Render report] end subgraph Reader E[Read in email] end B --> C D --> EUse case
Actors and the use cases inside a system boundary.
Edit in playgroundSource 14 lines
Mermaidusecase.mmd --- title: Online store --- usecase-beta direction LR actor Customer systemBoundary Store[Online store] Browse("Browse products") Pay("Pay for order") Authenticate("Authenticate") end Customer --> Browse Browse ..> : include Authenticate Pay --|> BrowseEvent modeling
Screens, commands, events and views across time frames.
Edit in playgroundSource 14 lines
Mermaideventmodeling.mmd --- title: Shopping cart events --- eventmodeling tf 01 ui CartUI tf 02 cmd AddItem tf 03 evt Cart.ItemAdded [[ItemAdded01]] tf 04 rmo Cart.CartView ->> 03 rf 05 pcr InventoryProcessor timeframe 06 event Inventory.Reserved data ItemAdded01 `json`{ "sku": "ABC", "quantity": 1 }
Charts 6
Pie
Parts of a whole, with optional values.
Edit in playgroundSource 6 lines
Mermaidpie.mmd pie showData title Sign-ins by method "Passkey" : 8900 "Authenticator app" : 6200 "SMS code" : 1300 "Password only" : 1500XY chart
Bars and lines on shared category and value axes.
Edit in playgroundSource 6 lines
Mermaidxychart.mmd xychart-beta title "Tickets closed per sprint" x-axis [S1, S2, S3, S4, S5, S6, S7, S8] y-axis "Tickets" 0 --> 120 bar [48, 61, 57, 72, 80, 77, 94, 103] line [48, 61, 57, 72, 80, 77, 94, 103]Sankey
Flows between stages, sized by volume.
Edit in playgroundSource 10 lines
Mermaidsankey.mmd --- title: Sign-ins by network and method --- sankey-beta Office network,Passkey,5200 Office network,Authenticator app,3100 Remote,Passkey,3700 Remote,Authenticator app,3100 Remote,SMS code,1300 Remote,Password only,1500Radar
Several measures compared on radial axes.
Edit in playgroundSource 7 lines
Mermaidradar.mmd radar-beta title Security posture axis mail["Mail auth"], dnssec["DNSSEC"], tls["TLS"], ct["CT"], policy["Policy"] curve current["Current"]{91, 72, 88, 95, 79} curve target["Target"]{95, 90, 95, 95, 90} min 0 max 100Treemap
Hierarchical totals as nested rectangles.
Edit in playgroundSource 11 lines
Mermaidtreemap.mmd --- title: Device inventory --- treemap-beta "Infrastructure" "Identity": 42 "Messaging": 18 "Endpoints" "Windows": 24 "macOS": 9 "Linux": 6Quadrant
Items placed on two axes split into four quadrants.
Edit in playgroundSource 12 lines
Mermaidquadrant.mmd quadrantChart title Feature priorities x-axis Low effort --> High effort y-axis Low impact --> High impact quadrant-1 Plan carefully quadrant-2 Do now quadrant-3 Maybe later quadrant-4 Avoid Dark theme: [0.25, 0.85] PNG export: [0.7, 0.8] Tooltips: [0.35, 0.4] Custom fonts: [0.8, 0.3]
Thinking tools 6
Mind map
Ideas branching out from a central topic.
Edit in playgroundSource 17 lines
Mermaidmindmap.mmd --- title: What ChartForgeX covers --- mindmap root((ChartForgeX)) Outputs SVG PNG HTML Authoring Fluent C# Markdown fences Mermaid Hosts Reports Email DashboardsTree view
A folder or outline hierarchy.
Edit in playgroundSource 11 lines
Mermaidtreeview.mmd --- title: Repository layout --- treeView-beta "src" "ChartForgeX" "VisualBlocks" "ChartForgeX.Mermaid" "MermaidParser.cs" "MermaidTreeViewParser.cs" "README.md"Venn
Proportional set circles, real intersections and reported area-fit limits.
Edit in playgroundSource 6 lines
Mermaidvenn.mmd venn-beta set A[First]: 100 set B[Second]: 60 union A,B[Shared]: 25 style A fill:#ee4455,fill-opacity:0.25,stroke-width:3 style A,B fill:#2233ff,fill-opacity:1,stroke:#112233,stroke-width:2Ishikawa
Causes grouped by category behind one effect.
Edit in playgroundSource 12 lines
Mermaidishikawa.mmd --- title: Why the release slipped --- ishikawa-beta Delayed release People Handoffs Timezone gaps Process Late review Platform Slow buildWardley
Components mapped by visibility and evolution.
Edit in playgroundSource 22 lines
Mermaidwardley.mmd wardley-beta title Platform map size [900, 600] evolution Genesis -> Custom Built -> Product -> Commodity anchor User [0.95, 0.05] component Portal [0.80, 0.35] inertia component API [0.70, 0.45] (build) component Identity [0.55, 0.65] label [-12, 18] User -> Portal Portal +'uses'> API API -.-> Identity;optional evolve API 0.75 note "Operational pressure" [0.35, 0.75] annotations [0.12, 0.88] annotation 1, [0.60, 0.50] "Improve automation" accelerator Faster [0.42, 0.62] deaccelerator Risk [0.48, 0.68] pipeline API { component Build [0.30] component Buy [0.55] component Commodity [0.80] }Cynefin
Situations sorted into Cynefin decision domains.
Edit in playgroundSource 13 lines
Mermaidcynefin.mmd cynefin-beta title Service decisions complex "Discover demand" complicated "Analyze capacity" chaotic "Contain outage" clear "Run checklist" confusion "Investigate context" complex --> complicated : "Learn"
Semantic fixtures use Mermaid.js 12.2.0, with additional reference lanes pinned to 10.9.8 and 11.17.2. These examples do not establish complete compatibility with every release or syntax form. The support matrix lists the documented syntax, native models and limits.
Use it from .NET
The atlas renders come from these calls. Install ChartForgeX.Mermaid for diagrams, and the Markdown bridge when documents hold mermaid fences.
Render Mermaid from C#
using ChartForgeX.Mermaid;
using ChartForgeX.VisualArtifacts;
MermaidRenderResult result = MermaidRenderer.Render(source);
if (!result.HasErrors && result.Artifact != null) {
result.Artifact.SaveSvg("diagram.svg");
result.Artifact.SavePng("diagram.png");
}
Check result.Diagnostics even when rendering succeeds. Warnings identify syntax or configuration that was kept without an exact visual interpretation.
Render Mermaid fences in Markdown
Add ChartForgeX.Markup.Mermaid when Markdown documents contain mermaid fences. The bridge keeps the dependency boundary clean: ChartForgeX.Mermaid owns parsing and conversion, and the markup bridge only adapts fence metadata and diagnostics.
using ChartForgeX.Markup.Mermaid;
var result = new MermaidVisualMarkupParser().Parse(markdown);
How rendering differs from Mermaid.js
- Diagrams are laid out and drawn by ChartForgeX, so the output uses your ChartForgeX theme and typography rather than Mermaid's CSS.
- The
defaultanddarkthemes select native static palettes. Supported color and font variables configure native presentation roles; other theme settings retain diagnostics. - Accessible titles and descriptions from
accTitleandaccDescrbecome the SVG's accessible name and description. - Remote fonts are never fetched; native font resolution uses the registered fonts and fallbacks.
The support matrix lists each native model, supported grammar and remaining limitation. Journey retains task scores and actors; Timeline retains categorical periods without inventing dates. C4 preserves real hierarchy, and quantitative Venn fits report their residual limits. Railroad frontends share one native grammar scene, while Agentflow and ZenUML source remains inert diagram data.