Skip to content

Diagram Truncation Exceeds Expected Size Limits #7777

Description

@kacemabidi12

Description

When a diagram’s source text exceeds 50 000 characters, Mermaid silently replaces the entire diagram with the placeholder:

  • graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa
    This truncation occurs even when the diagram is otherwise valid (e.g., a large flowchart with thousands of nodes). Users receive no warning or partial rendering, which leads to loss of information and a confusing experience.

Steps to reproduce

  1. Create a diagram whose Markdown definition is longer than 50 000 characters. Example: a flowchart with 10 000 nodes (node1, node2, … node10000).
  2. Embed the diagram in an element with the class mermaid on a web page.
  3. Load the page in any browser (Chrome, Firefox, etc.).

Result: The diagram is replaced by the “Maximum text size in diagram exceeded” message instead of being rendered.

Screenshots

No response

Code Sample


Setup

  • Mermaid version:
  • Browser and Version: [Chrome, Edge, Firefox]

Suggested Solutions

  1. Remove or increase the hard limit – Allow diagrams of any reasonable size to render, or at least raise the limit to a much higher value (e.g., 500 000 characters).
  2. Add a warning – If a diagram is unusually large, log a warning to the console instead of truncating it.
  3. Graceful degradation – Consider rendering a partial diagram or splitting it into multip

Additional Context

The limit was likely introduced for performance or security reasons, but it is too restrictive for real‑world use cases. Many users have reported similar issues in the wild (e.g., #7472, #7501). A more flexible approach would improve usability without compromising stability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageNeeds to be verified, categorized, etcType: Bug / ErrorSomething isn't working or is incorrect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions