Skip to main content
Documentation

Mermaid diagrams in Markdown: architecture views that survive code review

GitHub renders Mermaid natively, so diagrams live in the repo and diff in PRs. The syntax that pays off, plus the mistakes that leave a broken diagram in your README.

Thien Nguyen
By Thien Nguyen
Updated July 21, 2026 · 3 min read

Yes — you can commit an architecture diagram as text and have it render automatically. GitHub has rendered fenced ```mermaid blocks natively since February 2022, GitLab does too, and VS Code shows them in Markdown preview. That's the whole pitch: the diagram is source, so it sits next to the code, diffs in a pull request, and can't drift into a stale PNG that nobody remembers how to edit.

flowchart LR
  Browser --> API
  API --> Queue
  Queue --> Worker
  Worker --> Database

The real payoff shows up in review. When a PR adds a call from the API straight to the database, a reviewer sees the diagram edge is now wrong in the same diff and asks about it. A diagram in a separate design tool never gets that scrutiny.

Pick the diagram type by the question it answers

You need to showUseOne-line starter
What calls whatflowchart LRA --> B
Message order over timesequenceDiagramClient->>API: request
How data entities relateerDiagramUSER ||--o{ ORDER : places
Allowed state transitionsstateDiagram-v2Idle --> Running

A worked sequence example, with real participants for a login flow:

sequenceDiagram
  participant U as User
  participant W as Web app
  participant A as Auth server
  U->>W: click "Log in"
  W->>A: redirect with PKCE challenge
  A-->>U: login form
  U->>A: credentials
  A-->>W: authorization code
  W->>A: code + verifier
  A-->>W: access token

Takeaway: that diagram is nine lines of text. It renders on GitHub, diffs cleanly when the flow changes, and answers "what talks to the auth server, and in what order" faster than three paragraphs of prose ever will.

Mistakes that leave a broken diagram in your README

  1. Special characters in a label without quotes. A[Cache (Redis)] fails to parse because of the parentheses. Quote it: A["Cache (Redis)"]. Same for colons, brackets, and slashes.
  2. Deployment hostnames as node names. Label nodes with stable nouns — Billing worker, not billing-prod-e7a. The infrastructure churns; the architecture doesn't.
  3. One diagram trying to show everything. If a reader needs a zoom control, split it. GitHub also caps diagram size and will silently show a syntax error on very large graphs. Several focused views beat one wall.
  4. Forgetting the exact fence. It must be ```mermaid, lowercase. ```Mermaid or a plain ``` renders as a code block, not a diagram — a common "why won't it render" moment.
  5. Not previewing before you push. Mermaid's parser is strict; one bad edge breaks the whole diagram. Preview it in an editor or a live editor first, so review isn't the place you discover the syntax error.

Mermaid won't make a tangled architecture simple. What it does is make a small, honest view cheap enough that keeping it current stops being a chore — and a diagram nobody dreads updating is the only kind that stays true.

Cover photo by Ivan S on Pexels.

References

Primary documentation and specifications checked when this article was last updated.

DocumentationArchitectureMermaid

Related articles

All articles