
Native Mermaid 12.0.0 semantics translated and rendered on Compose Canvas, supporting all 33 diagram families with deterministic SceneGraph, extensive visual-parity testing, themes, and WebView-free rendering.
English · 简体中文
Native Mermaid rendering for Kotlin and Compose Multiplatform.
Mermaid 12.0.0 semantics translated to Kotlin and rendered with Compose Canvas.
Live Web demo · 8,448-case independent-scenario visual report · Full stability report · 33-diagram roadmap · Integration
[!IMPORTANT] CMP Mermaid implements all 33 official diagram families from Mermaid
12.0.0. Swimlanes has been revalidated after a direct upstream translation: its classic-look production, 256-case visual, and per-edge topology gates are current. The overall Mermaid12.0.0contract remains not Stable because Architecture's legalrandomize: truepath and legallook: handDrawninput return documentedMermaidError.UnsupportedFeatureresults, and seven detail cases remain under review: five Architecture and two Kanban. The full JVM and Wasm core suites pass.The current 8,448-case Native/Official independent-scenario visual report gives every family 256 real, label-normalized Mermaid sources. Flowchart retains its dedicated coverage corpus; the other 32 families use the complete 256-combination matrix of eight family-specific capability axes. Source, duplicate, detail, geometry, and 528 contact-sheet gates preserve the result. The 441 hand-authored production scenarios and 8,448 text/layout stress inputs remain separate evidence layers.
CMP Mermaid is designed for applications that render many diagrams without a
WebView per diagram. The production path does not embed Mermaid.js and does not
include a network client or require android.permission.INTERNET: parsing,
diagram state, layout preparation, SceneGraph generation, and final Compose
Canvas painting are owned by the multiplatform libraries.
All 33 implemented families retain repository-controlled tests and corpus data, published Native/Official captures, and passing replacement detail and geometry gates.
| Evidence | Result |
|---|---|
| Official Mermaid diagram families | 33 |
| Implemented diagram families | 33/33 |
| Translation pending | Architecture randomize: true spectral/Matrix/SVD path; non-default packing, tiling, radial, and bendpoint branches remain mapped unsupported |
| Flowchart per-edge topology | 256 pass, 0 fail |
| Independent production scenarios | 441 Native/Official pairs |
| Declared capability coverage | 738/738 |
| Independent-scenario visual matrix | 8,448 Native/Official pairs; Flowchart has its dedicated 256-case corpus and every other family has all 256 combinations of eight capability axes |
| Coverage hard gate | Every family has 256/256 label-normalized sources; non-Flowchart axes are balanced 128/128, pairwise balanced 64/64/64/64, and each axis changes all 128 paired sources |
| Duplicate hard gate | Every family has 256/256 unique blueprints, normalized semantics, and label-normalized sources; rendered manifest/PNG uniqueness is diagnostic because distinct legal inputs can render equivalently |
| Text/layout stress inputs | 8,448 byte-distinct inputs derived from the 441 production scenarios; tracked separately and not counted as structural coverage |
| Native/Official captures | 16,896 independent-scenario screenshots plus 882 independent-corpus and 16,896 malformed-source screenshots |
| Source-mutation parity | 8,448/8,448 Official accept/reject outcomes matched: 2,156 accepted and 6,292 rejected; every Native rejection was CONTENT_ERROR; 0 crashes or timeouts |
| Independent-scenario detail audit | 33 families: 8,441 pass, 7 review, 0 fail |
| Automated visual geometry | 8,448/8,448 pairs: 0 failure, 0 review findings |
| Deterministic SceneGraph replay | 441 passed, 0 mismatches |
| Built-in theme matrix | 363/363 |
| Separate generated Native stress inputs | 7,936 retained historical baseline |
| JVM tests | Core: 1,019 passed, 0 failed; Compose: 38 passed, 0 failed |
| Wasm tests | Core: 1,017 passed, 0 failed; Compose: 37 passed, 0 failed; debug UI: 9 passed, 0 failed |
| Core production soak | Historical 415-case baseline: 2,075 renders, 674ms total, 1ms P95, 63,968 bytes retained heap |
| Physical-device runtime matrix | Kotlin 2.3.20 Android 8/8, Kotlin 1.7.21 Android 8/8, and iOS 6/6 passed; 9,702 corpus renders; 198 reviewed sentinels plus 22 completion screenshots; 0 crashes or Android ANRs |
| Runtime load matrix | All three physical-device tracks passed all 441 cases; Web retains the prior 397-scenario baseline; iOS Simulator and Desktop retain the prior 236-scenario baseline |
| Evidence document | What it contains |
|---|---|
| Full diagram roadmap | Official 33-family inventory and current family-gate state |
| Stability test report | Current decision, visual evidence, tests, soak metrics, runtime load evidence, and reproduction steps |
| All 8,448 Native/Official independent scenarios | 528 paged contact sheets, with 16 different same-source scenarios per page |
| Source-mutation Native/Official evidence | 8,448 AI-like mutations from byte-distinct stress bases derived from 441 structural scenarios, 16,896 screenshots, and 528 comparison sheets |
| Android physical-device report | Separate Kotlin 2.3.20 and Kotlin 1.7.21 matrices across Android 9-16 |
| iOS physical-device report | Six-device iOS 14.3-26.0 matrix with complete 441-case loads |
| Production capability matrix | The 738 independently exercised capabilities |
| Production readiness | Code-level Stable criteria, resource budgets, and integration guidance |
| Quality Gate | Current automated JVM, build, publication, security, APK, visual, and Web load results |
| Full Visual Parity | Weekly/manual capture and detail enforcement for all 33 families |
| Full Invalid Source Matrix | Weekly/manual 33 × 256 Native/Official malformed-source safety matrix |
All fresh Swimlanes translation, topology, visual, JVM, Wasm, production
isolation, and publication gates have completed. The refreshed Flowchart
matrix has 107 unique graph topologies and passes all 256 per-edge routing
cases. Overall Mermaid 12.0.0 support remains not Stable until the
Architecture gaps, seven detail reviews, and legal RoughJS-backed unsupported
handDrawn look are resolved.
A legal feature that cannot be represented faithfully returns
MermaidError.UnsupportedFeature instead of silently drawing a misleading
approximation.
The comparisons below use the same Mermaid source, theme, layout mode, and fixed viewport. The goal is equivalent meaning and comparable visual quality, not pixel-identical browser output; platform font metrics may differ.
Flowchart: multi-region failover
| CMP Native - Compose Canvas | Official - Mermaid.js 12.0.0
|
|---|---|
![]() |
![]() |
XY Chart: mixed bar and line series
| CMP Native - Compose Canvas | Official - Mermaid.js 12.0.0
|
|---|---|
![]() |
![]() |
State Diagram: labels, loops, branches, and terminal states
| CMP Native - Compose Canvas | Official - Mermaid.js 12.0.0
|
|---|---|
![]() |
![]() |
The current published report contains 441 independent production comparisons plus 8,448 independent-scenario visual cases. A separate 8,448-input text/layout stress corpus remains available for wrapping and layout-pressure regressions: open all 528 independent-scenario visual-evidence pages.
| Diagram | Status | Production cases | Main coverage | Details |
|---|---|---|---|---|
| Flowchart | Detail and topology gates passed | 14 | Jison/FlowDB, Dagre, shapes, links, Markdown/HTML labels; topology 256 pass / 0 fail | Compatibility |
| XY Chart | Detail gate passed | 13 | Jison/XY DB, D3 scales and ticks, bar/line plots, labels | Compatibility |
| Quadrant Chart | Detail gate passed | 13 | Axes, quadrants, points, classes, direct styles, themes | Compatibility |
| Timeline | Detail gate passed | 13 | LR/TD layouts, sections, periods, events, color scales, themes | Compatibility |
| Kanban | Detail gate passed | 13 | Sections, tasks, metadata, priorities, ticket links, themes | Compatibility |
| Sequence | Detail gate passed | 14 | Actors, 26 message forms, notes, activations, control regions | Compatibility |
| Class | Detail gate passed | 13 | Compartments, generics, namespaces, relations, Dagre | Compatibility |
| State | Detail gate passed | 13 | Composite states, concurrency, notes, forks/joins, Dagre | Compatibility |
| Entity Relationship | Detail gate passed | 13 | Attributes, cardinalities, relationships, nested subgraphs | Compatibility |
| Gantt | Detail gate passed | 13 | Dates, dependencies, exclusions, milestones, D3-style ticks | Compatibility |
| Pie | Detail gate passed | 13 | Langium grammar, D3 angles, donut, legends, palettes | Compatibility |
| User Journey | Detail gate passed | 13 | Sections, scores, actors, satisfaction faces, text strategies | Compatibility |
| Requirement | Detail gate passed | 13 | SysML types and fields, elements, seven relationships, Dagre, styling | Compatibility |
| Git Graph | Detail gate passed | 13 | Langium grammar, branches, merges, cherry-picks, orientations, themes | Compatibility |
| Mindmap | Detail gate passed | 13 | Jison/Mindmap DB, CoSE-Bilkent, Dagre, tidy tree, shapes, themes | Compatibility |
| Packet | Detail gate passed | 13 | Langium grammar, explicit and counted fields, row splitting, fixed-grid rendering | Compatibility |
| Radar | Detail gate passed | 13 | Langium grammar, axes, curves, graticules, legends, themes | Compatibility |
| Sankey | Detail gate passed | 13 | CSV grammar, D3 Sankey layout, alignments, value labels, link and node colors | Compatibility |
| Treemap | Detail gate passed | 13 | Langium grammar, D3 hierarchy and squarify layout, classes, values, responsive sizing | Compatibility |
| Venn | Detail gate passed | 13 | Jison grammar, Venn.js/fmin optimization, weighted overlaps, styles, text nodes | Compatibility |
| Ishikawa | Detail gate passed | 13 | Jison indentation grammar, alternating recursive branches, fish-head geometry, wrapping | Compatibility |
| Cynefin | Detail gate passed | 13 | Five domains, deterministic boundaries, confusion overflow, transitions, themes | Compatibility |
| Event Modeling | Detail gate passed | 13 | Langium grammar, frames, swimlanes, data, relations, validation, themes | Compatibility |
| Agentflow | Detail gate passed | 13 | Jison grammar, typed nodes and edges, nested/global/collapsed flows, connectors, metadata, Dagre | Compatibility |
| Block | Detail gate passed | 13 | Jison grammar, grids, spans, composites, shapes, block arrows, links, classes, styles | Compatibility |
| Swimlanes | Revalidated; handDrawn unsupported | 13 | Direct upstream lane-aware Sugiyama translation, orthogonal routing, direction transforms, 256/256 topology pass | Compatibility |
| Architecture | Default layout translated; 5 detail reviews; randomize: true unsupported |
13 | Langium grammar, services, groups, junctions, directional edges, constrained fCoSE layout, icons | Compatibility |
| C4 | Detail gate passed | 13 | Five C4 levels, nested boundaries, deployment nodes, relation variants, styles, and configuration | Compatibility |
| Railroad | Detail gate passed | 18 | Railroad IR, EBNF, ABNF, PEG, shared AST, routed grammar paths, styles, and configuration | Compatibility |
| TreeView | Detail gate passed | 13 | Indentation and box-drawing syntax, hierarchy, annotations, descriptions, icons, styles, and configuration | Compatibility |
| Use Case | Detail gate passed | 18 | Actors, boundaries, UML relationships, notes, JSON tables, styles, and configuration | Compatibility |
| Wardley Map | Detail gate passed | 13 | Value chains, sourcing, evolution, pipelines, annotations, and strategic forces | Compatibility |
| ZenUML | Detail gate passed | 13 | Participants, nested calls, replies, groups, fragments, and participant icons | Compatibility |
All 33 implemented types support Mermaid frontmatter, relevant metadata, Unicode, and the relevant theme variables within their documented compatibility boundaries.
Open the live Kotlin/Wasm demo to browse syntax, render the galleries, switch all 11 themes, and compare CMP Native output with the pinned Mermaid.js reference. Every supported diagram type has an editable Playground with Native/Official preview switching. Mindmap can switch among CoSE-Bilkent, Dagre, and tidy-tree layouts.
The official comparison renderer belongs to mermaid-debug-ui only.
mermaid-core and mermaid-compose never use Mermaid.js.
Mermaid source
-> Kotlin preprocessor and translated parser
-> translated diagram database and layout preparation
-> platform-independent MermaidScene
-> Compose Canvas
mermaid-core owns parsing, diagram state, layout adapters, typed errors,
themes, and the platform-independent SceneGraph.mermaid-compose owns Canvas painting, text measurement, assets,
interactions, and pan/zoom behavior.mermaid-debug-ui owns documentation, galleries, Playground, official
comparison, and load-test screens. It is optional and should remain outside
production release variants.sample/* contains thin Android, iOS, Desktop, and Web launchers around the
shared debug UI.The production libraries contain no JavaScript engine or bundled JavaScript
algorithm. Pure Kotlin Dagre is the default unified layout. ELK names and
flowchart-elk are recognized as upstream inputs but return
MermaidError.UnsupportedFeature("ELK layout"); they are never silently
substituted with another layout.
The current publication coordinates are:
| Consumer | Artifact |
|---|---|
| Current Kotlin Multiplatform | io.github.swithun-liu:mermaid-core:0.1.10 |
| Current Compose Multiplatform | io.github.swithun-liu:mermaid-compose:0.1.10 |
Android with Kotlin 1.7.21
|
io.github.swithun-liu:mermaid-core-android-kotlin17:0.1.10 |
Android Compose with Kotlin 1.7.21
|
io.github.swithun-liu:mermaid-compose-android-kotlin17:0.1.10 |
| iOS binary |
CMPMermaid CocoaPod 0.1.10
|
Current Kotlin Multiplatform projects:
dependencies {
implementation("io.github.swithun-liu:mermaid-compose:0.1.10")
}[!NOTE] The Maven coordinates above are published and resolvable from the configured public repository. CocoaPods distribution remains a separate binary release path.
Android projects pinned to Kotlin 1.7.21 use the isolated Android artifact:
dependencies {
implementation(
"io.github.swithun-liu:mermaid-compose-android-kotlin17:0.1.10",
)
}The Kotlin 1.7.21 artifacts are Android-only, target JVM 1.8, and require
Android API 24 or newer. Their artifact names are intentionally distinct from
the current KMP modules, so a consumer cannot accidentally resolve Kotlin 2.x
metadata.
Android View-based hosts can use the same Compose renderer without compiling Compose source:
val diagramView = CMPMermaidView(context).apply {
setMermaidSource("flowchart LR\n A --> B")
setMermaidContentDescription("Example Mermaid diagram")
setMermaidErrorListener { error ->
reportRenderFailure(error.type, error.message, error.source)
}
}
container.addView(diagramView)CMPMermaidView is available from both the current Android target and the
Kotlin 1.7.21 Android artifact.
iOS projects can consume the precompiled static XCFramework through CocoaPods:
pod 'CMPMermaid', '0.1.10'The binary exposes CMPMermaidViewControllerFactory.makeViewController(...)
to Swift and includes all renderer font resources. It supports iOS device
arm64 and simulator arm64/x86_64 with a deployment target of iOS 14.
CMPMermaidViewControllerFactory().makeViewController(
source: source,
contentDescription: "Mermaid diagram",
onContentSizeChanged: nil,
onError: { error in
reportRenderFailure(error.type, error.message, error.source)
}
)For a source checkout:
dependencies {
implementation(project(":mermaid-compose"))
debugImplementation(project(":mermaid-debug-ui"))
}Basic Compose usage:
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.swithun.cmpmermaid.compose.MermaidDiagram
import com.swithun.cmpmermaid.core.MermaidTheme
import com.swithun.cmpmermaid.core.MermaidThemePreset
@Composable
fun Diagram(source: String) {
MermaidDiagram(
source = source,
modifier = Modifier.fillMaxWidth(),
theme = MermaidTheme.preset(MermaidThemePreset.Default),
contentDescription = "Mermaid diagram",
onError = { error ->
reportRenderFailure(error.type, error.message, error.source)
},
)
}The error callback receives MermaidRenderErrorInfo, including the original
source passed to the renderer.
CONTENT_ERROR represents structured parse, configuration, resource-limit, or
unsupported-content failures. UNEXPECTED_EXCEPTION represents an ordinary
exception caught inside the render pipeline or Compose drawing boundary.
The Compose surface renders Mermaid.js 12.0.0's standard error diagram while
the callback and onRenderResult retain the detailed typed diagnostic. The
published source-mutation corpus verifies Official accept/reject outcome parity
for all 8,448 mutations. Native rejected inputs remain typed CONTENT_ERROR;
exact diagnostic-message equality is reported separately for 1,798/6,292
paired errors and is not manufactured as a compatibility requirement.
Coroutine cancellation and fatal process errors continue to propagate.
Generate all KMP publications under build/maven-repository:
./gradlew \
:mermaid-core:publishAllPublicationsToBuildRepository \
:mermaid-compose:publishAllPublicationsToBuildRepositoryGenerate the Kotlin 1.7.21 Android artifacts with JDK 11:
./android-legacy-build/gradlew -p android-legacy-build \
assembleRelease \
verifyLegacyPublicationCoordinates \
publishLegacyToReleaseRepositoryGenerate and verify the static iOS binary with JDK 17:
./gradlew :mermaid-compose:podPublishReleaseXCFramework
tools/release/verify-ios-xcframework.shThe Quality Gate builds and verifies the iOS XCFramework once and preserves it
with its exact source commit. Pushing a v* tag then builds the modern KMP and
Kotlin 1.7.21 Android artifacts in parallel while reusing only the successful
verified iOS artifact from the successful main push Quality Gate for that
immutable tag commit. All outputs are joined and verified again before any
public registry is updated.
An interrupted publication keeps its prerelease and verified workflow artifact
for 14 days. Re-run the failed jobs, or manually run the Release workflow
with the same immutable tag. Maven Central and CocoaPods are checked before
each write, so an already-published version is verified and skipped instead of
being uploaded again.
All 11 Mermaid 12.0.0 presets are included:
default, dark, forest, neutral, base, neo, neo-dark, redux,
redux-color, redux-dark, and redux-dark-color.
Business themes can start from a preset with Kotlin copy, or consume
Mermaid-compatible themeVariables through MermaidTheme.withVariables(...).
Invalid external values are returned as GMResult.Err.
val brandTheme = MermaidTheme.preset(MermaidThemePreset.ReduxColor).copy(
background = SceneColor(0xFF101820),
nodeFill = SceneColor(0xFFF2AA4C),
nodeText = SceneColor(0xFF101820),
edge = SceneColor(0xFFF2AA4C),
)Arbitrary themeCSS depends on browser DOM/CSS semantics and returns
MermaidError.UnsupportedFeature. Portable styling uses typed Kotlin theme
objects and MermaidFontFamilyResolver.
CMP Mermaid follows a source-mapped translation workflow rather than reimplementing behavior from screenshots:
Source maps: Flowchart · XY Chart · Quadrant Chart · Timeline · Kanban · Sequence · Class · State · ER · Gantt · Pie · User Journey · Requirement · Git Graph · Mindmap · Packet · Radar · Sankey · Treemap · Venn · Ishikawa · Cynefin · Event Modeling · Agentflow · Block
Run the JVM and publication gates:
./gradlew \
:mermaid-core:jvmTest \
:mermaid-compose:jvmTest \
verifyPublicationCoordinatesRun the samples:
./gradlew :sample:androidApp:installDebug
./gradlew :sample:desktopApp:run
./gradlew :sample:webApp:wasmJsBrowserDevelopmentRunThe stability test report contains the complete cross-platform build and Native/Official visual reproduction commands.
CMP Mermaid is released under the MIT License. Translated Mermaid behavior and development-only reference assets retain their upstream notices in THIRD_PARTY_NOTICES.md.
English · 简体中文
Native Mermaid rendering for Kotlin and Compose Multiplatform.
Mermaid 12.0.0 semantics translated to Kotlin and rendered with Compose Canvas.
Live Web demo · 8,448-case independent-scenario visual report · Full stability report · 33-diagram roadmap · Integration
[!IMPORTANT] CMP Mermaid implements all 33 official diagram families from Mermaid
12.0.0. Swimlanes has been revalidated after a direct upstream translation: its classic-look production, 256-case visual, and per-edge topology gates are current. The overall Mermaid12.0.0contract remains not Stable because Architecture's legalrandomize: truepath and legallook: handDrawninput return documentedMermaidError.UnsupportedFeatureresults, and seven detail cases remain under review: five Architecture and two Kanban. The full JVM and Wasm core suites pass.The current 8,448-case Native/Official independent-scenario visual report gives every family 256 real, label-normalized Mermaid sources. Flowchart retains its dedicated coverage corpus; the other 32 families use the complete 256-combination matrix of eight family-specific capability axes. Source, duplicate, detail, geometry, and 528 contact-sheet gates preserve the result. The 441 hand-authored production scenarios and 8,448 text/layout stress inputs remain separate evidence layers.
CMP Mermaid is designed for applications that render many diagrams without a
WebView per diagram. The production path does not embed Mermaid.js and does not
include a network client or require android.permission.INTERNET: parsing,
diagram state, layout preparation, SceneGraph generation, and final Compose
Canvas painting are owned by the multiplatform libraries.
All 33 implemented families retain repository-controlled tests and corpus data, published Native/Official captures, and passing replacement detail and geometry gates.
| Evidence | Result |
|---|---|
| Official Mermaid diagram families | 33 |
| Implemented diagram families | 33/33 |
| Translation pending | Architecture randomize: true spectral/Matrix/SVD path; non-default packing, tiling, radial, and bendpoint branches remain mapped unsupported |
| Flowchart per-edge topology | 256 pass, 0 fail |
| Independent production scenarios | 441 Native/Official pairs |
| Declared capability coverage | 738/738 |
| Independent-scenario visual matrix | 8,448 Native/Official pairs; Flowchart has its dedicated 256-case corpus and every other family has all 256 combinations of eight capability axes |
| Coverage hard gate | Every family has 256/256 label-normalized sources; non-Flowchart axes are balanced 128/128, pairwise balanced 64/64/64/64, and each axis changes all 128 paired sources |
| Duplicate hard gate | Every family has 256/256 unique blueprints, normalized semantics, and label-normalized sources; rendered manifest/PNG uniqueness is diagnostic because distinct legal inputs can render equivalently |
| Text/layout stress inputs | 8,448 byte-distinct inputs derived from the 441 production scenarios; tracked separately and not counted as structural coverage |
| Native/Official captures | 16,896 independent-scenario screenshots plus 882 independent-corpus and 16,896 malformed-source screenshots |
| Source-mutation parity | 8,448/8,448 Official accept/reject outcomes matched: 2,156 accepted and 6,292 rejected; every Native rejection was CONTENT_ERROR; 0 crashes or timeouts |
| Independent-scenario detail audit | 33 families: 8,441 pass, 7 review, 0 fail |
| Automated visual geometry | 8,448/8,448 pairs: 0 failure, 0 review findings |
| Deterministic SceneGraph replay | 441 passed, 0 mismatches |
| Built-in theme matrix | 363/363 |
| Separate generated Native stress inputs | 7,936 retained historical baseline |
| JVM tests | Core: 1,019 passed, 0 failed; Compose: 38 passed, 0 failed |
| Wasm tests | Core: 1,017 passed, 0 failed; Compose: 37 passed, 0 failed; debug UI: 9 passed, 0 failed |
| Core production soak | Historical 415-case baseline: 2,075 renders, 674ms total, 1ms P95, 63,968 bytes retained heap |
| Physical-device runtime matrix | Kotlin 2.3.20 Android 8/8, Kotlin 1.7.21 Android 8/8, and iOS 6/6 passed; 9,702 corpus renders; 198 reviewed sentinels plus 22 completion screenshots; 0 crashes or Android ANRs |
| Runtime load matrix | All three physical-device tracks passed all 441 cases; Web retains the prior 397-scenario baseline; iOS Simulator and Desktop retain the prior 236-scenario baseline |
| Evidence document | What it contains |
|---|---|
| Full diagram roadmap | Official 33-family inventory and current family-gate state |
| Stability test report | Current decision, visual evidence, tests, soak metrics, runtime load evidence, and reproduction steps |
| All 8,448 Native/Official independent scenarios | 528 paged contact sheets, with 16 different same-source scenarios per page |
| Source-mutation Native/Official evidence | 8,448 AI-like mutations from byte-distinct stress bases derived from 441 structural scenarios, 16,896 screenshots, and 528 comparison sheets |
| Android physical-device report | Separate Kotlin 2.3.20 and Kotlin 1.7.21 matrices across Android 9-16 |
| iOS physical-device report | Six-device iOS 14.3-26.0 matrix with complete 441-case loads |
| Production capability matrix | The 738 independently exercised capabilities |
| Production readiness | Code-level Stable criteria, resource budgets, and integration guidance |
| Quality Gate | Current automated JVM, build, publication, security, APK, visual, and Web load results |
| Full Visual Parity | Weekly/manual capture and detail enforcement for all 33 families |
| Full Invalid Source Matrix | Weekly/manual 33 × 256 Native/Official malformed-source safety matrix |
All fresh Swimlanes translation, topology, visual, JVM, Wasm, production
isolation, and publication gates have completed. The refreshed Flowchart
matrix has 107 unique graph topologies and passes all 256 per-edge routing
cases. Overall Mermaid 12.0.0 support remains not Stable until the
Architecture gaps, seven detail reviews, and legal RoughJS-backed unsupported
handDrawn look are resolved.
A legal feature that cannot be represented faithfully returns
MermaidError.UnsupportedFeature instead of silently drawing a misleading
approximation.
The comparisons below use the same Mermaid source, theme, layout mode, and fixed viewport. The goal is equivalent meaning and comparable visual quality, not pixel-identical browser output; platform font metrics may differ.
Flowchart: multi-region failover
| CMP Native - Compose Canvas | Official - Mermaid.js 12.0.0
|
|---|---|
![]() |
![]() |
XY Chart: mixed bar and line series
| CMP Native - Compose Canvas | Official - Mermaid.js 12.0.0
|
|---|---|
![]() |
![]() |
State Diagram: labels, loops, branches, and terminal states
| CMP Native - Compose Canvas | Official - Mermaid.js 12.0.0
|
|---|---|
![]() |
![]() |
The current published report contains 441 independent production comparisons plus 8,448 independent-scenario visual cases. A separate 8,448-input text/layout stress corpus remains available for wrapping and layout-pressure regressions: open all 528 independent-scenario visual-evidence pages.
| Diagram | Status | Production cases | Main coverage | Details |
|---|---|---|---|---|
| Flowchart | Detail and topology gates passed | 14 | Jison/FlowDB, Dagre, shapes, links, Markdown/HTML labels; topology 256 pass / 0 fail | Compatibility |
| XY Chart | Detail gate passed | 13 | Jison/XY DB, D3 scales and ticks, bar/line plots, labels | Compatibility |
| Quadrant Chart | Detail gate passed | 13 | Axes, quadrants, points, classes, direct styles, themes | Compatibility |
| Timeline | Detail gate passed | 13 | LR/TD layouts, sections, periods, events, color scales, themes | Compatibility |
| Kanban | Detail gate passed | 13 | Sections, tasks, metadata, priorities, ticket links, themes | Compatibility |
| Sequence | Detail gate passed | 14 | Actors, 26 message forms, notes, activations, control regions | Compatibility |
| Class | Detail gate passed | 13 | Compartments, generics, namespaces, relations, Dagre | Compatibility |
| State | Detail gate passed | 13 | Composite states, concurrency, notes, forks/joins, Dagre | Compatibility |
| Entity Relationship | Detail gate passed | 13 | Attributes, cardinalities, relationships, nested subgraphs | Compatibility |
| Gantt | Detail gate passed | 13 | Dates, dependencies, exclusions, milestones, D3-style ticks | Compatibility |
| Pie | Detail gate passed | 13 | Langium grammar, D3 angles, donut, legends, palettes | Compatibility |
| User Journey | Detail gate passed | 13 | Sections, scores, actors, satisfaction faces, text strategies | Compatibility |
| Requirement | Detail gate passed | 13 | SysML types and fields, elements, seven relationships, Dagre, styling | Compatibility |
| Git Graph | Detail gate passed | 13 | Langium grammar, branches, merges, cherry-picks, orientations, themes | Compatibility |
| Mindmap | Detail gate passed | 13 | Jison/Mindmap DB, CoSE-Bilkent, Dagre, tidy tree, shapes, themes | Compatibility |
| Packet | Detail gate passed | 13 | Langium grammar, explicit and counted fields, row splitting, fixed-grid rendering | Compatibility |
| Radar | Detail gate passed | 13 | Langium grammar, axes, curves, graticules, legends, themes | Compatibility |
| Sankey | Detail gate passed | 13 | CSV grammar, D3 Sankey layout, alignments, value labels, link and node colors | Compatibility |
| Treemap | Detail gate passed | 13 | Langium grammar, D3 hierarchy and squarify layout, classes, values, responsive sizing | Compatibility |
| Venn | Detail gate passed | 13 | Jison grammar, Venn.js/fmin optimization, weighted overlaps, styles, text nodes | Compatibility |
| Ishikawa | Detail gate passed | 13 | Jison indentation grammar, alternating recursive branches, fish-head geometry, wrapping | Compatibility |
| Cynefin | Detail gate passed | 13 | Five domains, deterministic boundaries, confusion overflow, transitions, themes | Compatibility |
| Event Modeling | Detail gate passed | 13 | Langium grammar, frames, swimlanes, data, relations, validation, themes | Compatibility |
| Agentflow | Detail gate passed | 13 | Jison grammar, typed nodes and edges, nested/global/collapsed flows, connectors, metadata, Dagre | Compatibility |
| Block | Detail gate passed | 13 | Jison grammar, grids, spans, composites, shapes, block arrows, links, classes, styles | Compatibility |
| Swimlanes | Revalidated; handDrawn unsupported | 13 | Direct upstream lane-aware Sugiyama translation, orthogonal routing, direction transforms, 256/256 topology pass | Compatibility |
| Architecture | Default layout translated; 5 detail reviews; randomize: true unsupported |
13 | Langium grammar, services, groups, junctions, directional edges, constrained fCoSE layout, icons | Compatibility |
| C4 | Detail gate passed | 13 | Five C4 levels, nested boundaries, deployment nodes, relation variants, styles, and configuration | Compatibility |
| Railroad | Detail gate passed | 18 | Railroad IR, EBNF, ABNF, PEG, shared AST, routed grammar paths, styles, and configuration | Compatibility |
| TreeView | Detail gate passed | 13 | Indentation and box-drawing syntax, hierarchy, annotations, descriptions, icons, styles, and configuration | Compatibility |
| Use Case | Detail gate passed | 18 | Actors, boundaries, UML relationships, notes, JSON tables, styles, and configuration | Compatibility |
| Wardley Map | Detail gate passed | 13 | Value chains, sourcing, evolution, pipelines, annotations, and strategic forces | Compatibility |
| ZenUML | Detail gate passed | 13 | Participants, nested calls, replies, groups, fragments, and participant icons | Compatibility |
All 33 implemented types support Mermaid frontmatter, relevant metadata, Unicode, and the relevant theme variables within their documented compatibility boundaries.
Open the live Kotlin/Wasm demo to browse syntax, render the galleries, switch all 11 themes, and compare CMP Native output with the pinned Mermaid.js reference. Every supported diagram type has an editable Playground with Native/Official preview switching. Mindmap can switch among CoSE-Bilkent, Dagre, and tidy-tree layouts.
The official comparison renderer belongs to mermaid-debug-ui only.
mermaid-core and mermaid-compose never use Mermaid.js.
Mermaid source
-> Kotlin preprocessor and translated parser
-> translated diagram database and layout preparation
-> platform-independent MermaidScene
-> Compose Canvas
mermaid-core owns parsing, diagram state, layout adapters, typed errors,
themes, and the platform-independent SceneGraph.mermaid-compose owns Canvas painting, text measurement, assets,
interactions, and pan/zoom behavior.mermaid-debug-ui owns documentation, galleries, Playground, official
comparison, and load-test screens. It is optional and should remain outside
production release variants.sample/* contains thin Android, iOS, Desktop, and Web launchers around the
shared debug UI.The production libraries contain no JavaScript engine or bundled JavaScript
algorithm. Pure Kotlin Dagre is the default unified layout. ELK names and
flowchart-elk are recognized as upstream inputs but return
MermaidError.UnsupportedFeature("ELK layout"); they are never silently
substituted with another layout.
The current publication coordinates are:
| Consumer | Artifact |
|---|---|
| Current Kotlin Multiplatform | io.github.swithun-liu:mermaid-core:0.1.10 |
| Current Compose Multiplatform | io.github.swithun-liu:mermaid-compose:0.1.10 |
Android with Kotlin 1.7.21
|
io.github.swithun-liu:mermaid-core-android-kotlin17:0.1.10 |
Android Compose with Kotlin 1.7.21
|
io.github.swithun-liu:mermaid-compose-android-kotlin17:0.1.10 |
| iOS binary |
CMPMermaid CocoaPod 0.1.10
|
Current Kotlin Multiplatform projects:
dependencies {
implementation("io.github.swithun-liu:mermaid-compose:0.1.10")
}[!NOTE] The Maven coordinates above are published and resolvable from the configured public repository. CocoaPods distribution remains a separate binary release path.
Android projects pinned to Kotlin 1.7.21 use the isolated Android artifact:
dependencies {
implementation(
"io.github.swithun-liu:mermaid-compose-android-kotlin17:0.1.10",
)
}The Kotlin 1.7.21 artifacts are Android-only, target JVM 1.8, and require
Android API 24 or newer. Their artifact names are intentionally distinct from
the current KMP modules, so a consumer cannot accidentally resolve Kotlin 2.x
metadata.
Android View-based hosts can use the same Compose renderer without compiling Compose source:
val diagramView = CMPMermaidView(context).apply {
setMermaidSource("flowchart LR\n A --> B")
setMermaidContentDescription("Example Mermaid diagram")
setMermaidErrorListener { error ->
reportRenderFailure(error.type, error.message, error.source)
}
}
container.addView(diagramView)CMPMermaidView is available from both the current Android target and the
Kotlin 1.7.21 Android artifact.
iOS projects can consume the precompiled static XCFramework through CocoaPods:
pod 'CMPMermaid', '0.1.10'The binary exposes CMPMermaidViewControllerFactory.makeViewController(...)
to Swift and includes all renderer font resources. It supports iOS device
arm64 and simulator arm64/x86_64 with a deployment target of iOS 14.
CMPMermaidViewControllerFactory().makeViewController(
source: source,
contentDescription: "Mermaid diagram",
onContentSizeChanged: nil,
onError: { error in
reportRenderFailure(error.type, error.message, error.source)
}
)For a source checkout:
dependencies {
implementation(project(":mermaid-compose"))
debugImplementation(project(":mermaid-debug-ui"))
}Basic Compose usage:
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.swithun.cmpmermaid.compose.MermaidDiagram
import com.swithun.cmpmermaid.core.MermaidTheme
import com.swithun.cmpmermaid.core.MermaidThemePreset
@Composable
fun Diagram(source: String) {
MermaidDiagram(
source = source,
modifier = Modifier.fillMaxWidth(),
theme = MermaidTheme.preset(MermaidThemePreset.Default),
contentDescription = "Mermaid diagram",
onError = { error ->
reportRenderFailure(error.type, error.message, error.source)
},
)
}The error callback receives MermaidRenderErrorInfo, including the original
source passed to the renderer.
CONTENT_ERROR represents structured parse, configuration, resource-limit, or
unsupported-content failures. UNEXPECTED_EXCEPTION represents an ordinary
exception caught inside the render pipeline or Compose drawing boundary.
The Compose surface renders Mermaid.js 12.0.0's standard error diagram while
the callback and onRenderResult retain the detailed typed diagnostic. The
published source-mutation corpus verifies Official accept/reject outcome parity
for all 8,448 mutations. Native rejected inputs remain typed CONTENT_ERROR;
exact diagnostic-message equality is reported separately for 1,798/6,292
paired errors and is not manufactured as a compatibility requirement.
Coroutine cancellation and fatal process errors continue to propagate.
Generate all KMP publications under build/maven-repository:
./gradlew \
:mermaid-core:publishAllPublicationsToBuildRepository \
:mermaid-compose:publishAllPublicationsToBuildRepositoryGenerate the Kotlin 1.7.21 Android artifacts with JDK 11:
./android-legacy-build/gradlew -p android-legacy-build \
assembleRelease \
verifyLegacyPublicationCoordinates \
publishLegacyToReleaseRepositoryGenerate and verify the static iOS binary with JDK 17:
./gradlew :mermaid-compose:podPublishReleaseXCFramework
tools/release/verify-ios-xcframework.shThe Quality Gate builds and verifies the iOS XCFramework once and preserves it
with its exact source commit. Pushing a v* tag then builds the modern KMP and
Kotlin 1.7.21 Android artifacts in parallel while reusing only the successful
verified iOS artifact from the successful main push Quality Gate for that
immutable tag commit. All outputs are joined and verified again before any
public registry is updated.
An interrupted publication keeps its prerelease and verified workflow artifact
for 14 days. Re-run the failed jobs, or manually run the Release workflow
with the same immutable tag. Maven Central and CocoaPods are checked before
each write, so an already-published version is verified and skipped instead of
being uploaded again.
All 11 Mermaid 12.0.0 presets are included:
default, dark, forest, neutral, base, neo, neo-dark, redux,
redux-color, redux-dark, and redux-dark-color.
Business themes can start from a preset with Kotlin copy, or consume
Mermaid-compatible themeVariables through MermaidTheme.withVariables(...).
Invalid external values are returned as GMResult.Err.
val brandTheme = MermaidTheme.preset(MermaidThemePreset.ReduxColor).copy(
background = SceneColor(0xFF101820),
nodeFill = SceneColor(0xFFF2AA4C),
nodeText = SceneColor(0xFF101820),
edge = SceneColor(0xFFF2AA4C),
)Arbitrary themeCSS depends on browser DOM/CSS semantics and returns
MermaidError.UnsupportedFeature. Portable styling uses typed Kotlin theme
objects and MermaidFontFamilyResolver.
CMP Mermaid follows a source-mapped translation workflow rather than reimplementing behavior from screenshots:
Source maps: Flowchart · XY Chart · Quadrant Chart · Timeline · Kanban · Sequence · Class · State · ER · Gantt · Pie · User Journey · Requirement · Git Graph · Mindmap · Packet · Radar · Sankey · Treemap · Venn · Ishikawa · Cynefin · Event Modeling · Agentflow · Block
Run the JVM and publication gates:
./gradlew \
:mermaid-core:jvmTest \
:mermaid-compose:jvmTest \
verifyPublicationCoordinatesRun the samples:
./gradlew :sample:androidApp:installDebug
./gradlew :sample:desktopApp:run
./gradlew :sample:webApp:wasmJsBrowserDevelopmentRunThe stability test report contains the complete cross-platform build and Native/Official visual reproduction commands.
CMP Mermaid is released under the MIT License. Translated Mermaid behavior and development-only reference assets retain their upstream notices in THIRD_PARTY_NOTICES.md.