Mermaid Visual Standard

Purpose

Mermaid is a semantic visual language, not a box-sizing system.

The primary goal is to make meaning visible while preserving natural Mermaid geometry.

The canonical model is:

SHAPE
→ structural entity type

COLOR
→ semantic / epistemic status

EMOJI
→ concept identity

EDGE
→ relation type / epistemic force

SUBGRAPH
→ context / perspective / boundary

The diagram should remain understandable even when color or emoji is ignored.

Core principles

  1. Semantics first.
  2. Natural geometry.
  3. Small, stable visual vocabulary.
  4. Consistent meanings across diagrams.
  5. No presentation hacks in Mermaid source.
  6. Renderer owns geometry; publication layer owns global presentation scale.

Do not redesign a graph merely to make all diagrams occupy the same canvas size.

A diagram may naturally be wider, taller, or denser when its meaning requires it.

Scope and applicability

These rules apply to all Mermaid diagram types, not only flowcharts. Apply the semantic intent through the notation and visual channels that the selected type actually provides. The vocabulary is shared; its syntax is not forced onto every diagram.

Semantic fidelity is mandatory in every diagram: every native construct must retain the meaning of the domain being modeled. Epistemic integrity is mandatory whenever a diagram represents knowledge, sources, observations, claims, evidence, hypotheses, uncertainty, contradiction, validation, or accepted understanding. Do not impose epistemic categories on diagrams that model only chronology, structure, interaction, or quantitative data.

For each diagram, use the applicable channels:

If a visual channel is unavailable, ambiguous, or misleading for a diagram type, leave it unused and preserve meaning in labels, structure, or a legend. Do not convert a diagram to a flowchart solely to gain access to shapes or styling.

Guidance by diagram family

These are semantic mappings, not mandatory syntax templates. Mermaid capabilities vary by diagram type and version; use only syntax supported by the target renderer.

The list is illustrative, not exhaustive. Apply the same reasoning to newer or specialized Mermaid diagram types.

Composition guidance

Prefer:

LR is allowed when the semantics are genuinely horizontal or when it materially improves readability.

The former diagram from “12. From DSL to Mermaid” remains a useful example of clear semantic composition, but it is not a mandatory size, topology, node-count, or footprint target.

Semantic + Epistemic Visual Vocabulary

Shape = structural type

Use a small shape vocabulary.

Structural role Preferred Mermaid form Typical concepts
orientation / state / synthesis / result rounded ([text]) Intent, Observation, Understanding, Result
process / assertion / transformation rectangle [text] Action, Claim, Evidence, Projection
unresolved branch / gate / tension diamond {text} Unknown, Decision, Contradiction, Validation Gate
source / store / corpus cylinder [(text)] Source, Reference, Dataset, Knowledge Store
context / layer / perspective / actor boundary subgraph Context, Perspective, Runtime Layer, Responsibility

Do not assign one unique shape to every concept.

Reuse the same shape whenever the structural category is the same.

Color = semantic or epistemic status

Canonical semantic palette:

classDef context fill:#D9EAF7,stroke:#7AA6C2,color:#3E342C,stroke-width:2px;
classDef observation fill:#DDF3E8,stroke:#78AA91,color:#3E342C,stroke-width:2px;
classDef claim fill:#FFF1BF,stroke:#C8A84E,color:#3E342C,stroke-width:2px;
classDef evidence fill:#E8DDF5,stroke:#A68BC4,color:#3E342C,stroke-width:2px;
classDef hypothesis fill:#F8DFC4,stroke:#C9986D,color:#3E342C,stroke-width:2px;
classDef uncertainty fill:#F6D6DD,stroke:#BF7C89,color:#3E342C,stroke-width:2px;
classDef contradiction fill:#F4CFC8,stroke:#B96B5D,color:#3E342C,stroke-width:2px;
classDef understanding fill:#DCEFD6,stroke:#86A878,color:#3E342C,stroke-width:2px;
classDef projection fill:#ECEBE8,stroke:#9C9992,color:#3E342C,stroke-width:2px;
classDef orchestration fill:#DDE3F4,stroke:#8998C8,color:#3E342C,stroke-width:2px;

Recommended meanings:

Color must communicate role, not decoration.

Emoji = concept identity

Recommended vocabulary:

Use at most one functional emoji per visible concept label unless there is a strong semantic reason to do otherwise. Apply one wherever a recommended symbol clearly fits and the diagram syntax permits it; do not limit emoji to roots or major nodes. Keep the same concept on the same emoji throughout a diagram and document.

Never change an identifier, exact label, command, requirement ID, or data value to insert emoji. Prefer a syntax-supported display alias or label. If none exists, or if no symbol clearly fits, omit emoji only from that item. Do not use diagram density or formality as blanket exemptions; omit an emoji only when it would materially reduce comprehension. Reviewers should be able to identify eligible labels and the concrete reason for any diagram-wide omission.

Edge = relation semantics

Primary accepted structural, operational, or semantic relation:

-->

Hypothesis, uncertainty, weak association, unresolved relation, or relation under inquiry:

-.->

In Mermaid source, use:

-. label .->

Use short edge labels such as:

Use feedback loops for revision, re-evaluation, inquiry, learning, or recurrence.

Do not visually imply evidential strength unless the content actually establishes it.

Subgraph = context / perspective / boundary

Use subgraph when a visible boundary clarifies:

Do not use subgraphs as decorative containers.

Epistemic integrity

Whenever any part of a diagram models knowledge, preserve these distinctions in the relevant nodes, labels, and relationships:

Citation ≠ Source
Source ≠ Evidence
Evidence ≠ Claim
Claim ≠ Understanding
Operational success ≠ Epistemic acceptance
Retrieval ≠ Semantic extraction
Generated citation span ≠ Source passage

Additional rules:

Canonical example

Mermaid diagram

This example is a semantic reference, not a required topology or footprint.

Refactor mode

When applying this skill to an existing diagram:

  1. read the surrounding content;
  2. identify the Mermaid diagram type and what it is meant to communicate;
  3. identify entity types, relation types, native type-specific semantics, and whether the diagram represents epistemic concepts;
  4. preserve domain semantics, not accidental topology or styling;
  5. when epistemic concepts are present, keep sources, observations, claims, evidence, uncertainty, contradiction, and accepted understanding distinct;
  6. map structural roles to native shapes or symbols where supported;
  7. apply semantic colors only where useful and supported;
  8. add a functional emoji to every eligible visible concept label, preserving exact identifiers and values through native display labels where supported; record any diagram-wide omission with its concrete syntax or comprehension reason;
  9. encode accepted vs uncertain relations only through a supported, truthful relation convention;
  10. use native grouping only for a real context or boundary;
  11. preserve domain-specific meanings such as ordering, cardinality, dates, and data values;
  12. render and inspect the result with the target Mermaid renderer when available.

Rebuild only when semantic clarity, reading order, or visual coherence requires it.

Do not reconstruct merely to match another diagram’s size.

Sizing and rendering

Source-level rule

Do not encode final presentation size into Mermaid source.

Avoid:

Natural geometry

Let Mermaid determine the natural geometry of:

Different shapes are expected to have different natural dimensions.

That difference is semantic and intentional.

Deterministic rendering

When a static renderer is available, prefer:

@mermaid-js/mermaid-cli@12.0.0

Canonical deterministic pipeline:

Mermaid source
→ mmdc 12.0.0
→ static SVG
→ preserve viewBox and internal geometry
→ optional single global display scale
→ responsive presentation

The publishing layer may reduce or enlarge the whole SVG uniformly.

It must not independently resize nodes or normalize individual diagrams with different fixed CSS widths.

Responsive presentation may use:

max-width: 100%;
height: auto;

For environments such as GitHub or VS Code that render Mermaid directly, keep the same semantic source and allow the host renderer to present it naturally.

Layout defaults

For flowcharts, prefer:

flowchart TD
nodeSpacing: 36
rankSpacing: 44
curve: basis
fontSize: 13px

These are defaults, not immutable laws.

Increase spacing before reducing typography.

Split a diagram when the semantic load becomes excessive.

Do not add nodes merely to reach a target node count.

Decision diamonds

Use a diamond only when the node genuinely represents:

Do not use diamonds simply to make the diagram visually varied.

Shape consistency

Variation is encouraged when it carries meaning.

The rule is:

same structural meaning
→ same shape

different structural meaning
→ shape may differ

Do not vary shapes for decoration.

Document-wide consistency

Across one document or product family, ensure:

Consistency means semantic consistency, not identical diagram dimensions.

Avoid

Authoring syntax

Use the Mermaid fence required by the current environment.

For ordinary Markdown / GitHub / VS Code, use the fenced code language mermaid.

For Jekyll repositories that explicitly require mermaid!, use the fenced code language mermaid!.

A Mermaid fence must contain a complete, valid diagram (for example, beginning with flowchart TD), not a placeholder such as .... When documenting fence syntax, write it inline rather than nesting literal Mermaid fences in Markdown pages processed by the static renderer.

Fence conversion is a publishing concern. Do not modify diagram semantics during that conversion.

Quality gate

Before accepting a diagram, verify:

Guiding principles

Preserve semantic meaning, not existing topology.

Shape expresses what kind of thing it is.

Color expresses what epistemic or semantic status it has.

Emoji identifies the concept.

Edge style expresses the nature of the relation.

Let the renderer preserve natural geometry.

Consistency is semantic consistency, not identical footprint.