← Blog
9 min readThe Moxie Docs team

Mermaid Diagrams for Developers: Examples, Syntax, and a Free Live Editor

Learn Mermaid diagram syntax with live flowchart, sequence, ER, class, and state examples. Paste into a free browser Mermaid live editor for instant preview, shareable links, and SVG/PNG export.

  • mermaid
  • documentation
  • developer-tools
  • architecture

Mermaid is a text-based diagram language that turns a few lines of Markdown-friendly syntax into flowcharts, sequence diagrams, entity-relationship models, class diagrams, state machines, Gantt charts, and more. If you have ever pasted a mermaid code fence into a GitHub README and watched it render on the pull request page, you already know the appeal: diagrams that live next to the code, version control cleanly, and do not require opening Visio or Figma for a simple architecture sketch.

This guide is a practical tour of Mermaid diagrams for software teams - what they are good for, the syntax patterns you will use most often, copy-paste examples, and how to edit them in a free online Mermaid live editor when you want instant preview and export without installing anything.

If you want to try examples as you read, open the free Mermaid live editor in another tab. Every diagram on this page also has an Edit control that loads the same source into that tool.

Why Mermaid diagrams stick in engineering workflows#

Teams keep adopting Mermaid for a few durable reasons:

  1. Diff-friendly. A flowchart is a text change in a pull request, not a binary asset nobody can review.
  2. Works where docs already live. GitHub, GitLab, many static site generators, and documentation platforms render Mermaid natively or with a small plugin.
  3. Fast to draft. You can sketch a request path or schema relationship while writing the design doc, without context-switching into a drawing tool.
  4. Portable. The source is plain text. Share a gist, a README section, or a URL that encodes the diagram.

The tradeoff is familiar to anyone who has written YAML: the syntax is simple until it is not. A free Mermaid diagram editor with live preview closes that gap - you type, see the result, fix a typo, export SVG or PNG when you need a slide or a wiki page.

Mermaid flowchart example (architecture and decision trees)#

Flowcharts are the default diagram type for system overviews, onboarding maps, and branchy decision logic. Start with a direction (TD top-down, LR left-right), then connect nodes with arrows.

Syntax notes

  • flowchart LR sets layout left-to-right (TD / TB for top-down).
  • Node shapes: [rectangle], (rounded), {diamond}, [(cylinder)] for datastores.
  • Edge labels use A -->|label| B.
  • Subgraphs group related services when the chart gets crowded.

Flowcharts are the right Mermaid diagram when you need “how does a request move through the system?” more than “which tables reference which.”

Mermaid sequence diagram example (APIs and auth)#

Sequence diagrams show time-ordered messages between participants. They are ideal for login flows, webhooks, and multi-service handshakes.

Syntax notes

  • participant renames actors (Auth as Identity service).
  • Solid arrows ->> are requests; dashed -->> are responses.
  • Note over A,B: text and alt / opt / loop blocks cover branches without drawing spaghetti.

When the question is “who calls whom, and in what order?”, start with a Mermaid sequence diagram instead of a flowchart.

Mermaid ER diagram example (data models)#

Entity-relationship diagrams document tables, keys, and relationships. They pair well with migration reviews and onboarding for backend teams.

Syntax notes

  • Relationships: ||--o{ (one-to-many), ||--|| (one-to-one), }o--o{ (many-to-many).
  • Column lines use a simple type token, then name, then optional PK / FK / UK.
  • Keep names alphanumeric; Mermaid is pickier than SQL about special characters.

If you already have CREATE TABLE SQL and do not want to hand-write Mermaid ER syntax, the free SQL to ER diagram generator converts common Postgres, MySQL, and SQLite table definitions into a Mermaid erDiagram with live preview and SVG export.

Mermaid class diagram example (modules and domain types)#

Class diagrams show types, fields, methods, and dependencies. Use them for domain models and for explaining how packages talk to each other without dumping a full dependency graph.

Syntax notes

  • class Name { ... } holds members; + public, - private is common convention.
  • Relationships: --> association, <|-- inheritance, *-- composition.
  • Keep the chart small. A full monorepo class dump is unreadable; document the slice the reader needs.

Mermaid state diagram example (lifecycle and status machines)#

State diagrams clarify allowed transitions: job status, subscription lifecycle, PR review states.

Use state diagrams when illegal transitions are expensive (billing, indexing, deployments) and prose alone leaves “can we go from Failed back to Running?” ambiguous.

Gantt and planning charts#

Mermaid Gantt charts are lightweight release timelines - fine for a design doc, not a replacement for a project tool.

Putting Mermaid diagrams in GitHub and Markdown docs#

A Mermaid fence in Markdown looks like this:

MARKDOWN
```mermaid
flowchart TD
  A[Start] --> B[Done]
```

GitHub renders those fences in README files, issues, and pull request descriptions. Many static doc sites (Docusaurus, MkDocs with a plugin, VitePress plugins, and others) do the same.

Practical tips

  • Prefer smaller diagrams. A PR that adds a 200-line chart is hard to review.
  • Name nodes for the reader, not for the implementation file path.
  • When a diagram changes with the code, put it next to the module it describes - or accept that it will drift.
  • For slides and Confluence, export SVG or PNG from a Mermaid live editor so you are not screenshotting a half-zoomed browser tab.

Free Mermaid live editor: preview, share, export#

Hand-writing Mermaid in a text area without feedback is how most people learn the hard way that a missing arrow or quote breaks the chart. A dedicated Mermaid diagram editor should:

  • Render live as you type - no save-and-reload loop.
  • Stay private for day-to-day sketching (diagrams in the browser, not uploaded by default).
  • Share via URL so a teammate sees the exact same source.
  • Export SVG and PNG for docs, tickets, and decks.
  • Ship examples for flowchart, sequence, ER, class, mindmap, and Gantt so you are never starting from a blank page.

That is what the free Moxie Docs Mermaid live editor is built for:

FeatureWhat you get
Live previewInstant render while you edit Mermaid source
Shareable linksDiagram encoded in the URL - no account required
SVG / PNG exportClean downloads for docs and slides
ExamplesFlowchart, sequence, ER, class, mindmap, Gantt starters
Private by designParsing and rendering run in your browser
Edit from docsDiagrams on Moxie pages link into the editor with source preloaded

Open it when you are learning Mermaid syntax, reviewing a diagram before pasting it into a README, or exporting a chart for a design review. No signup for the free tool path.

Mermaid vs drawing tools (and when to use each)#

NeedPrefer MermaidPrefer a visual board
Architecture sketch in a PRYesSometimes overkill
Pixel-perfect product mockNoYes
Sequence of API callsYesPossible but slower
Workshop whiteboardingText-first Mermaid can lagReal-time canvas wins
Long-lived system map in gitYesExport + re-import gets messy

Mermaid wins when the diagram is part of the engineering record. Drawing tools win when the artifact is primarily visual collaboration.

Keeping diagrams true as the codebase changes#

A Mermaid flowchart in a README is only as good as last week’s understanding of the system. The failure mode is familiar: the service was split, the auth path changed, and the diagram still shows the old boxes.

That is a documentation problem, not a Mermaid syntax problem.

Moxie Docs connects to GitHub, indexes the repository, and keeps generated architecture docs and diagrams aligned with source over time - with reviewable Cleanup PRs rather than silent overwrites. Use the free Mermaid editor to draft and export quickly; connect a repo when you want those diagrams and the surrounding docs to stay current on every merge.

Quick Mermaid cheatsheet#

GoalStart with
System overviewflowchart LR or flowchart TD
Request lifecyclesequenceDiagram
Database schemaerDiagram (or SQL → ER tool)
Domain typesclassDiagram
Job / subscription lifecyclestateDiagram-v2
Rough timelinegantt
Categories / sharepie

Try it now#

  1. Open the free Mermaid diagram editor.
  2. Load a flowchart or sequence example, or paste one of the fences from this article.
  3. Tweak labels until the diagram matches your system.
  4. Copy the Mermaid source into a README, or export SVG/PNG for a design review.
  5. When you need ER diagrams from real CREATE TABLE SQL, use the SQL to ER diagram generator.

Mermaid diagrams work because they treat architecture as text: reviewable, searchable, and close to the code. A live editor removes the friction of learning the syntax. Living docs remove the friction of keeping the pictures honest after the next merge.

Republish or cite this article

You're welcome to republish this piece in full or in part. We just ask that you credit the original with a link back. See our republishing guidelines.

Attribution snippet

<p>This article was originally published on <a href="https://moxiedocs.com/blog/mermaid-diagrams-examples-and-free-live-editor">Moxie Docs</a>.</p>

Cite this article

The Moxie Docs team. "Mermaid Diagrams for Developers: Examples, Syntax, and a Free Live Editor." Moxie Docs, July 10, 2026, https://moxiedocs.com/blog/mermaid-diagrams-examples-and-free-live-editor.

Try it on your repo

Put your own codebase on the same footing.

Searchable docs, MCP-ready context, and Cleanup PRs that keep everything current as the code changes.