Mermaid diagrams in documentation, with examples
Write diagrams as text in the same file as the prose. They review like a paragraph, they never drift from the docs they illustrate, and nobody has to find the original file to change an arrow.
Why a diagram should be text
A flowchart, for a decision or a path
```mermaid
flowchart TD
A[Push to main] --> B{Docs changed?}
B -- No --> C[Skip build]
B -- Yes --> D[Build site]
D --> E{Build passed?}
E -- No --> F[Keep last live build]
E -- Yes --> G[Publish]
```A sequence diagram, for who calls whom
```mermaid
sequenceDiagram
autonumber
participant R as Reader
participant CDN
participant App
participant DB
R->>CDN: GET /guide/install
CDN-->>R: 200 (cached)
R->>App: GET /private/runbook
App->>DB: check site password
DB-->>App: hash
App-->>R: 302 to login
```A state diagram, for a thing with a lifecycle
```mermaid
stateDiagram-v2
[*] --> Queued
Queued --> Building
Building --> Live: success
Building --> Failed: error
Failed --> Queued: retry
Live --> Building: republish
Live --> [*]
```Two more worth knowing
An entity relationship diagram, for a data model
```mermaid
erDiagram
ACCOUNT ||--o{ PROJECT : owns
PROJECT ||--o{ BUILD : produces
BUILD ||--|| ARTIFACT : stores
PROJECT }o--o| DOMAIN : "answers at"
```A gantt chart, for a migration with dates
```mermaid
gantt
title API v1 deprecation
dateFormat YYYY-MM-DD
section Notice
Deprecation announced :done, 2026-01-15, 30d
section Migration
v2 available :active, 2026-02-15, 120d
section Shutdown
v1 read-only :2026-06-15, 30d
v1 removed :milestone, 2026-07-15, 0d
```When not to draw one
| If the content is | Use |
|---|---|
| Steps in order, no branches | A numbered list |
| A decision with two or three branches | A flowchart |
| Parties exchanging messages in order | A sequence diagram |
| A status field and its legal transitions | A state diagram |
| Tables and how they relate | An ER diagram |
| Comparable values across options | A table, not a chart |
| A screenshot of your own interface | A screenshot |
| A system with forty boxes | Three diagrams, one per layer |
Questions
How do I add a Mermaid diagram to Markdown?
What diagram types does Mermaid support?
Are Mermaid diagrams good for accessibility?
Do Mermaid diagrams survive an export?
Should I use Mermaid or a drawing tool?
Try the free plan instead of reading about it
- Drag in a folder of Markdown, a zip, a Word document or a PDF
- Search, navigation and a 404 page are built for you
- Export the built site or the source on every plan, free included
Full-text search in docs without paying for an index
Search on a documentation site does not have to be a subscription. For most doc sets the index is small enough to build at publish time and ship with the pages, which costs nothing and works offline.
Contrast and readability in docs themes (WCAG AA in practice)
A brand colour that looks right on a marketing page is often unreadable as a link in body text, and worse again in dark mode. What AA actually requires, which parts of a docs theme break first, and how to stop choosing badly.
Docszero vs MkDocs: the same site, without the pipeline
MkDocs is free and always will be. What costs is the hosting, the CI job and the afternoons. Docszero builds with Zensical, the Material for MkDocs team’s own successor, and publishes it for you.