A Mermaid diagram can render correctly in one Markdown preview and fail as raw code in another without the document changing. The usual cause is not Markdown itself: each viewer bundles its own Mermaid release, configuration, and security policy. Syntax accepted by a current Mermaid build may be unknown to an older renderer embedded in a documentation site, editor, or browser tool.
This guide is about version compatibility. For repairing malformed arrows, labels, or diagram structure, use the separate broken Mermaid diagram guide.
Before debugging a large diagram, test a small flowchart in both environments:
If this remains a code block, the preview may not enable Mermaid at all. If it renders while the original diagram fails, the problem is more likely a diagram type, syntax feature, directive, or configuration introduced after the destination's Mermaid version.
xychart Versus xychart-betaXY charts are a visible example of version drift. Current Mermaid documentation uses xychart, while older integrations may recognize the earlier xychart-beta identifier:
If the destination rejects the first line, try the identifier supported by that renderer before changing the axis or data. The complete Mermaid bar-chart guide owns bar syntax, multiple-series examples, labels, and axis configuration.
Mermaid adds diagram types and promotes experimental syntax over time. A current playground may understand an architecture diagram or XY-chart option that an editor extension bundled months earlier does not.
When a newer diagram type fails:
Do not assume that installing a newer Mermaid CLI changes the renderer inside GitHub, VS Code, a static-site generator, or an online viewer. Those are separate runtimes.
A basic diagram may render while newer frontmatter settings are ignored. Current XY charts, for example, expose options for orientation, dimensions, title visibility, axis presentation, and data labels. An older integration may understand the chart but not a recently added configuration key.
Reduce the diagram in layers:
This separates a parser problem from an unsupported configuration option. It also produces a small example suitable for an issue report.
Mermaid labels can include characters that pass through Markdown, HTML, and Mermaid parsing. The order differs between integrations. HTML entities, raw tags, click directives, and externally loaded resources may therefore behave differently even when both tools report similar Mermaid versions.
For portable diagrams:
A security restriction is not necessarily a syntax bug. A viewer may intentionally disable interactive directives or remote content.
Use this sequence before rewriting a diagram:
The final step matters because a diagram-only playground does not reproduce the Markdown parser, page width, security policy, or theme used by the published document.
Upgrade the renderer when you control the application and need a newer diagram type across many documents. Rewrite for compatibility when the document must work on destinations you do not control.
A conservative shared-document baseline usually means established diagram types, simple quoted labels, no raw HTML, and minimal configuration. Keep the richer source only when every required destination supports it.
Open the complete file in mdview.io to test Mermaid beside the prose, tables, and code it explains. A successful render proves compatibility with that viewer; it does not guarantee that every other platform bundles the same Mermaid version.
The two environments may bundle different Mermaid versions or enable different diagram features. Test a minimal flowchart, then compare the failing diagram type and configuration.
xychart-beta to xychart always fix a bar chart?No. It only addresses the diagram identifier. The target must also support XY charts and every configuration option used by the diagram.
Yes. Validity is evaluated by a specific Mermaid release and host configuration. New syntax, HTML handling, security policies, themes, and page constraints can differ between destinations.