Why Mermaid Charts Fail Across Different Versions

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.

Start With a Minimal Compatibility Test

Before debugging a large diagram, test a small flowchart in both environments:

[Diagram]

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-beta

XY charts are a visible example of version drift. Current Mermaid documentation uses xychart, while older integrations may recognize the earlier xychart-beta identifier:

[Diagram]

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.

New Diagram Types Reach Renderers at Different Times

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:

  1. Identify the Mermaid version used by the environment where it works.
  2. Identify the version bundled by the final publishing destination.
  3. Check when the diagram type or option became available.
  4. Upgrade the destination if you control it.
  5. Otherwise, rewrite the diagram using syntax supported by both versions.

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.

Configuration Can Fail Even When Syntax Works

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:

  1. Remove the frontmatter configuration.
  2. Render the bare diagram.
  3. Restore one configuration group at a time.
  4. Stop at the first option that breaks the destination.

This separates a parser problem from an unsupported configuration option. It also produces a small example suitable for an issue report.

Security Levels and HTML Handling

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.

A Version-Compatibility Workflow

Use this sequence before rewriting a diagram:

  1. Confirm that a minimal flowchart renders.
  2. Record the first line that declares the diagram type.
  3. Remove frontmatter, initialization directives, and custom themes.
  4. Reduce the diagram to two nodes or one data series.
  5. Compare the Mermaid versions of both environments.
  6. Reintroduce features one at a time.
  7. Test the complete Markdown document at its final URL.

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.

When to Upgrade and When to Rewrite

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.

Mermaid Version FAQ

Why does Mermaid render on GitHub but not in my editor?

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.

Does changing 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.

Can a valid Mermaid diagram still be non-portable?

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.