10 Copy-Paste Mermaid Diagram Examples for 2026
Discover 10 practical Mermaid diagram examples you can copy-paste. Includes flowcharts, sequence, ERDs, and more for stunning docs-as-code.
Static diagrams usually fail for one reason. They live outside the codebase, so nobody updates them when the system changes.
Mermaid fixed a real workflow problem. Teams can write diagrams as text in Markdown, keep them in the repo, review them in pull requests, and ship them through the same docs pipeline as the rest of the project. That changes team behavior. Diagrams stop being slide-deck artifacts and start acting like source files.
That matters because diagram quality is really maintenance quality. A flowchart that changes with an endpoint rename stays useful. A state diagram reviewed with the feature branch catches bad assumptions before they hit production. Good API documentation developers actually read works the same way. It stays close to the implementation and easy to update.
Mermaid covers the diagrams developers reach for most often, from request flows and service interactions to ERDs, class diagrams, and architecture views. One syntax will not replace every visual tool, and it should not. Large stakeholder presentations, dense product roadmaps, and highly polished design artifacts still benefit from dedicated diagram software. But for engineering docs, docs-as-code usually wins on speed, reviewability, and long-term accuracy.
GitDocAI makes that setup practical. Store Mermaid blocks in Markdown or MDX. Keep them next to the code they describe. Publish them with the rest of your docs. When a pull request changes an endpoint, lifecycle, or schema, the diagram can change in the same review cycle.
The examples below are built for that workflow. Each one is copy-pasteable, tied to a real documentation job, and paired with GitDocAI tips that help the diagram keep earning its spot in the repo.
Table of Contents
- 1. Flowchart for API Request/Response Workflows
- 2. Sequence Diagrams for Multi-Service Interactions
- 3. Class Diagrams for SDK and Object Structure
- 4. State Diagrams for Stateful Resource Lifecycles
- 5. Entity Relationship Diagrams ERD for Data Models
- 6. Git Flow Diagrams for Contribution Workflows
- 7. Architecture Diagrams for System Topology
- 8. Deployment Pipeline Diagrams for Release Cycles
- 9. Decision Tree Diagrams for Configuration and Setup Paths
- 10. Swimlane Diagrams for Cross-Functional Workflows
- 10 Mermaid Diagram Examples Compared
- Bring Your Docs to Life with Mermaid
1. Flowchart for API Request/Response Workflows
Teams should start here. A flowchart is the fastest way to show how an endpoint behaves when auth succeeds, validation fails, or downstream work retries.
For API docs, that matters because developers don’t read controller code first. They want the path. A good flowchart makes an OAuth callback, a Stripe-style payment action, or a Twilio-style send-and-callback loop understandable in one screen.
Start with the happy path
flowchart TD
A([Client Request]) --> B[Validate API Key]
B --> C{Valid?}
C -->|Yes| D[Parse Payload]
C -->|No| E[Return 401]
D --> F{Payload OK?}
F -->|Yes| G[Process Request]
F -->|No| H[Return 400]
G --> I[Persist Result]
I --> J[Return 200]
This pattern works for request/response docs because it separates decision points from actions. Keep diamonds for decisions and rectangles for actions. If you mix shapes randomly, readers stop trusting the diagram.
Practical rule: Build one flowchart for the main path and another for major failure paths. One giant chart with every edge case usually becomes unreadable.
A good real-world use case is an authorization code flow. Show request start, identity provider redirect, code exchange, token validation, and final success. If you need more depth than that, switch to a sequence diagram instead of forcing more detail into a flowchart.
For GitDocAI, store this Mermaid block in the same page as your endpoint reference and link the surrounding explanation to your auth and error sections. That pairing works especially well in docs teams trying to produce API documentation developers actually read.
- Keep labels explicit: Write
YesandNo, orSuccessandFailure. Unlabeled branches create support tickets. - Match node names to code terms: Use the same names your API returns, such as
401 Unauthorizedorvalidation_error. - Avoid HTML-like text in nodes: Mermaid renderers can fail on angle brackets and HTML-like content, especially in documentation systems with stricter parsing, as seen in this rendering discussion about angle brackets and HTML tags.
2. Sequence Diagrams for Multi-Service Interactions
Sequence diagrams earn their keep when one user action triggers hidden choreography across services. Login flows, webhook processing, GraphQL federation, and event-driven callbacks all read better as time-based interactions than as boxes in a topology chart.
Use them when a single API call fans out to internal services or third parties. That’s the stuff developers can’t infer from a simple endpoint reference.
A quick visual helps before the details:

Show the calls people can’t see in code snippets
sequenceDiagram
participant Client
participant API
participant Auth
participant DB
participant Webhook
Client->>API: POST /checkout
API->>Auth: Validate token
Auth-->>API: Token valid
API->>DB: Create payment record
DB-->>API: Record saved
API-->>Client: 202 Accepted
API->>Webhook: Send payment event
Webhook-->>API: 200 OK
This is a strong fit for Stripe webhook delivery, Auth0 login, or Slack event processing. The point isn’t artistic accuracy. The point is call order, ownership, and what returns synchronously versus asynchronously.
If you’re publishing OpenAPI-driven docs, sequence diagrams fill a gap the spec usually doesn’t. An OpenAPI file tells readers what an endpoint accepts. It doesn’t show the choreography behind it. That’s why they pair well with auto-generated OpenAPI docs that stay in sync.
Keep sequence diagrams readable
The official Mermaid ecosystem and docs tooling increasingly treat Mermaid as a text-based syntax that renders directly in supported platforms, which is why editing diagrams beside Markdown works so well in day-to-day docs maintenance (Mermaid in documentation workflows). But readability still depends on discipline.
- Use participant names people recognize:
Gateway,Billing Service,Postgres,Twilio. Avoid internal nicknames. - Label arrows with real operations:
POST /token,INSERT payment,publish invoice.created. - Split large flows: One diagram for sign-in, one for token refresh, one for logout beats a monster sequence nobody can scan.
Later in the page, embed the walkthrough video if your docs team trains contributors on sequence notation:
3. Class Diagrams for SDK and Object Structure
SDK docs often fail at the same point. They list classes alphabetically but never show how the pieces fit together. A class diagram fixes that fast.
This is especially useful for Python, TypeScript, and Java SDKs where developers need to understand inheritance, composition, and shared response models before they start reading docstrings. Think Stripe-like resource objects, Firebase-style references and queries, or a client that owns message and completion objects.
Document the public surface, not the plumbing
classDiagram
class Client {
+createMessage()
+listMessages()
}
class Message {
+id
+role
+content
}
class ChatCompletion {
+id
+model
+output
}
Client --> Message : creates
Client --> ChatCompletion : returns
This works because it shows only the public interface. Internal helpers, transport adapters, retry middleware, and serializer classes usually don’t belong in customer-facing docs. They make the SDK look harder than it is.
Independent guides on Mermaid examples often show sequence and ER patterns for system interactions and data relationships, but the same benefit applies here. Structured text cuts ambiguity because the diagram can be reviewed like code instead of redrawn by hand in a separate tool (practical Mermaid patterns in technical documentation).
A useful test: if a developer never imports the class directly, it probably doesn’t belong in the published class diagram.
For GitDocAI, keep the diagram in the SDK overview page, then link class names in the surrounding prose to the actual reference pages generated from your repository. That gives readers a map first and the full API surface second.
- Group by package or module: One diagram for auth, one for resources, one for webhooks.
- Show relationships that change decisions: inheritance, composition, and factory return types matter most.
- Don’t fake UML completeness: you don’t need every private field to make a class diagram valuable.
4. State Diagrams for Stateful Resource Lifecycles
State diagrams stop expensive mistakes.
They matter anytime a resource has rules about what can happen next. Jobs, subscriptions, payment intents, tickets, and orders all have states that accept some actions and reject others. If the lifecycle is missing from the docs, integrators reverse-engineer it from error responses. That slows implementation and creates noisy support tickets.
Use states to document what the API allows
stateDiagram-v2
[*] --> Pending
Pending --> Processing: POST /jobs/{id}/start
Processing --> Succeeded: worker completes
Processing --> Failed: worker error
Pending --> Canceled: POST /jobs/{id}/cancel
Failed --> Pending: POST /jobs/{id}/retry
Succeeded --> [*]
Canceled --> [*]
This format works well because it answers the question developers have. “What can I do with this resource right now?” A flowchart shows process. A state diagram shows constraints. That difference matters when someone is wiring retries, webhook handlers, or admin actions.
The useful version is specific. Label transitions with the trigger that causes the move. Use the actual endpoint, webhook event, timeout rule, or background job outcome. If a transition is automatic, say so. If only the system can perform it, say that too. Those details prevent a common docs failure where every state is shown but nobody knows what causes the change.
For docs-as-code teams, state diagrams pull their weight when they live beside the schema, endpoint docs, and webhook definitions in the same repo. Keep the Mermaid block close to the resource docs. Review lifecycle changes in the same pull request as the code change. That keeps the diagram honest.
GitDocAI works well here because the diagram, the API reference, and the surrounding explanation can stay on one page. When a new retry path or terminal state lands in code, update the Mermaid block in the same commit so the published docs change with it.
- Mark terminal states clearly: show where no further user action is valid.
- Name the trigger on every important edge: endpoint, webhook, timeout, scheduler, or worker event.
- Document forbidden assumptions in prose: for example, canceled jobs cannot be retried, or succeeded jobs ignore update calls.
- Split human and system actions: readers need to know whether a transition comes from an API call or backend automation.
5. Entity Relationship Diagrams ERD for Data Models
ERDs work best when your API exposes relationships that users need to reason about. Multi-tenant SaaS schemas, order systems, social graphs, and project hierarchies all benefit from a clean entity map.
The mistake is trying to document the entire database. Public docs rarely need audit tables, migration tables, or internal denormalization layers. Show the model users interact with.
Keep the ERD tied to the product surface
erDiagram
ORGANIZATION ||--o{ USER : has
ORGANIZATION ||--o{ PROJECT : owns
PROJECT ||--o{ TASK : contains
USER ||--o{ TASK : assigned_to
ORGANIZATION {
string id
string name
}
USER {
string id
string email
}
PROJECT {
string id
string title
}
TASK {
string id
string status
}
This is enough to explain a workspace model, an e-commerce order domain, or a project management schema. It helps developers understand nesting, cardinality, and what objects depend on others before they write queries or parse payloads.
A practical trick is to mirror the same entity names used in API responses. If your API returns organization_id, don’t rename it to tenantId in the ERD because it looks cleaner. That disconnect creates friction.
Field note: The best ERDs explain query behavior indirectly. If a user sees that tasks belong to projects and projects belong to organizations, they’ll understand why list endpoints scope the way they do.
For GitDocAI, embed the ERD in your data model page and keep adjacent sections for object schemas, filtering rules, and soft-delete behavior. The diagram gives shape. The prose handles exceptions.
6. Git Flow Diagrams for Contribution Workflows
Most contribution docs are too abstract. They say “open a PR” and stop there. Contributors still don’t know whether to branch from main, whether release branches exist, or what blocks a merge.
A Git flow diagram makes the path concrete. That’s useful for open-source maintainers, internal platform teams, and any product where docs, code, and CI all move together.
Show the real workflow, not the aspirational one
flowchart LR
A[main] --> B[feature/my-change]
B --> C[Open Pull Request]
C --> D[CI Checks]
D --> E{Approved?}
E -->|Yes| F[Merge to main]
E -->|No| G[Revise Branch]
G --> C
F --> H[Deploy]
This is enough for GitHub Flow. If your team uses develop, release branches, or hotfix branches, add them only if contributors need to interact with them.
The trap is over-modeling. A full Git Flow diagram can be technically accurate and still be useless if your team mostly works trunk-based. Show what people do every week, not the branching theory from a slide deck.
For docs-as-code teams, this belongs right next to your contributing guide, review policy, and release notes process. GitDocAI is especially useful here because docs changes follow the same review path as code changes, which makes the workflow visible in one place. Pair the diagram with guidance on shipping docs as a team workflow.
- Mark protected branches: reviewers need to know what can’t be pushed directly.
- Name CI gates:
lint,test,docs build,security scanare more helpful thanchecks. - Show docs contributions too: if docs edits require the same PR path, say so in the diagram or nearby text.
7. Architecture Diagrams for System Topology
Architecture diagrams cut through guesswork fast. They show the system shape, the failure boundaries, and the dependencies that will matter during onboarding, debugging, and change review.
That makes them useful in API docs, platform setup guides, and incident runbooks. The job is simple. Show how requests move, where state lives, what runs async, and which external systems can break your happy path.
Here’s the kind of environment this diagram usually represents:

Map service boundaries before they drift from reality
flowchart TB
Client[Client Apps] --> Gateway[API Gateway]
Gateway --> App[Application Service]
App --> DB[(Primary Database)]
App --> Queue[Job Queue]
Queue --> Worker[Background Worker]
App --> Webhook[External Webhook Provider]
Worker --> Cache[(Cache)]
This example works because it answers the questions engineers ask. Which component owns writes? What happens off the request path? Which dependency sits outside your control? If this diagram lives next to the code that defines these services, it stays useful instead of becoming slideware.
For docs-as-code teams, architecture diagrams should live with the repo, not in a wiki graveyard. Keep the Mermaid source in Markdown near the service docs, review it in pull requests, and update it when a queue, cache, or provider is added. GitDocAI fits well here because the diagram can ship with the same changeset as the code and docs, which keeps topology docs aligned with what is deployed.
A common mistake is drawing too low. Teams start with a service map, then cram in subnets, pods, failover rules, and hostnames. That turns a readable topology diagram into an infrastructure screenshot in text form. Stay one abstraction layer above volatile details unless the reader needs deployment-level accuracy.
- Separate trust boundaries clearly: use subgraphs or styling for internal services, third-party providers, and user-facing entry points.
- Highlight stateful systems: databases, queues, and caches deserve visual weight because they shape failure modes and scaling limits.
- Show async paths on purpose: background workers and webhooks explain delayed behavior that confuses users and new team members.
- Keep names stable: label components by product or domain role, not temporary implementation details that change every quarter.
The payoff is speed. A new engineer can scan the page and understand the topology in seconds. A reviewer can spot whether a proposed change adds a new dependency, a new data store, or a new external risk surface before merge. That is the essential value of Mermaid here. Copy-pasteable diagrams that stay maintainable because they live in source control.
8. Deployment Pipeline Diagrams for Release Cycles
Pipeline diagrams are where docs-as-code stops being a slogan. If your team claims docs ship with code, the release path should show it.
This matters for engineering leads, technical writers, and DevRel teams because documentation publication often has hidden gates. Review, staging validation, production publish, and rollback rules all affect when users see updated docs.
Make approvals and rollback points visible
flowchart LR
A[Commit] --> B[Build]
B --> C[Test]
C --> D[Deploy to Staging]
D --> E{Manual Approval}
E -->|Approve| F[Deploy to Production]
E -->|Reject| G[Fix and Re-run]
F --> H[Publish Release Notes]
This works for GitHub Actions, GitLab CI, Jenkins, or a GitDocAI publication path where pending documentation updates are reviewed before going live. It also surfaces who owns each gate. That’s often the part teams forget to document.
Mermaid examples and community tutorials have increasingly shifted toward styling, front matter, themes, right-angle connectors, and custom variables. That tells you something important. Teams don’t just want syntax that parses. They want diagrams that can be standardized inside branded docs and remain readable in light and dark modes (advanced Mermaid styling and maintainability discussion).
For GitDocAI, keep the deployment diagram in your publishing or contributing docs. Then mirror your actual config files nearby, whether that’s .github/workflows, .gitlab-ci.yml, or another pipeline definition.
- Show manual gates explicitly: approval steps are invisible otherwise.
- Add rollback edges in prose if the diagram gets crowded: don’t force every recovery branch into one chart.
- Keep docs publication in scope: if the docs site publishes after code deploy, say so.
9. Decision Tree Diagrams for Configuration and Setup Paths
Decision trees are underrated in developer docs. They cut through setup ambiguity faster than long troubleshooting pages because they force you to encode the forks users face.
They shine in authentication setup, SDK selection, webhook configuration, and error diagnosis. If support keeps answering the same “which path applies to me?” question, a decision tree is probably the missing asset.
Decision trees work best when support already knows the forks
flowchart TD
A[Choose Authentication Method] --> B{Need user delegated access?}
B -->|Yes| C[Use OAuth 2.0]
B -->|No| D{Server to server only?}
D -->|Yes| E[Use API Key]
D -->|No| F{Strict transport identity required?}
F -->|Yes| G[Use mTLS]
F -->|No| H[Read advanced auth guide]
This is ideal for an auth page where users need to choose between OAuth, API keys, and mTLS. It’s also strong for troubleshooting trees like 401, 429, and 500 branches, as long as each leaf points to a concrete fix.
The common failure is too many branches per node. Keep it binary when possible. Once a node fans out into four or five choices, the chart starts reading like a cramped menu.
Use decision trees for routing decisions, not full procedures. Once the user reaches a leaf, hand them off to the detailed page.
For GitDocAI, put the tree at the top of the setup page and link each final node to a deeper guide in the same docs set. That lets AI-assisted search, navigation, and page generation reinforce the same structure instead of competing with it.
10. Swimlane Diagrams for Cross-Functional Workflows
Swimlane diagrams solve a different problem. Not system logic. Human handoffs.
They’re valuable when engineering, QA, security, DevOps, support, or legal all touch the same workflow. Release management, bug triage, documentation review, and onboarding processes usually benefit from lanes because the biggest confusion is ownership, not sequencing.
A simple visual cue helps frame that idea:

Use swimlanes when ownership is the problem
flowchart TB
subgraph Engineering
A[Implement Feature]
B[Open PR]
end
subgraph QA
C[Validate Behavior]
end
subgraph DevOps
D[Deploy Release]
end
subgraph Support
E[Update Internal Notes]
end
A --> B --> C --> D --> E
This pattern fits an API release flow, bug triage path, or a docs publishing workflow that crosses engineering, technical writing, product, and compliance. Mermaid doesn’t give you every BPMN feature, but for lightweight swimlanes inside docs, it usually gives you enough.
Limit the lane count. Once you push beyond a handful of teams, people stop reading across the chart and start scanning only their own row. If the process really requires more participants, split it into separate swimlane diagrams by phase.
For GitDocAI, use swimlanes in internal or auth-gated documentation where teams need the same source-controlled process map as the public docs. That keeps support playbooks, release procedures, and external documentation aligned instead of drifting apart.
10 Mermaid Diagram Examples Compared
| Diagram | Implementation complexity 🔄 | Resource requirements ⚡ | Expected outcomes 📊 | Ideal use cases 💡 | Key advantages ⭐ |
|---|---|---|---|---|---|
| Flowchart for API Request/Response Workflows | Medium, branches increase complexity | Low–Medium, diagram tool (Mermaid/Lucid), time to map flows | Clear step‑by‑step logic; highlights error paths | Endpoint logic, auth flows, error handling | Easy to follow logic; good for non‑technical readers; maps to REST docs ⭐⭐⭐⭐ |
| Sequence Diagrams for Multi‑Service Interactions | Medium–High, timelines and many actors can clutter | Medium, service details, timing data, diagram tooling | Visual ordering of calls; reveals latency and bottlenecks | Microservices, third‑party integrations, request lifecycles | Shows dependencies and timing; useful for onboarding and race condition detection ⭐⭐⭐⭐ |
| Class Diagrams for SDK and Object Structure | Medium, scales with codebase size | Medium, code parsing tools or manual extraction | Clear object relationships, public API surface | SDKs, client libraries, object models | Shows inheritance/composition; reduces time reading signatures ⭐⭐⭐⭐ |
| State Diagrams for Stateful Resource Lifecycles | Medium, nested states add complexity | Low–Medium, state/event mapping, update discipline | Explicit valid transitions; fewer invalid requests | Orders, subscriptions, jobs, lifecycle‑aware resources | Prevents invalid transitions; aids test generation and docs clarity ⭐⭐⭐⭐ |
| Entity Relationship Diagrams (ERD) for Data Models | High, large schemas become hard to read | Medium–High, DB schema access, modeling tools | Clear data relationships and cardinality; surfaces join issues | Database‑backed APIs, payload design, event models | Visualizes relations and foreign keys; aids query/design decisions ⭐⭐⭐ |
| Git Flow Diagrams for Contribution Workflows | Low–Medium, depends on chosen branching model | Low, repo examples, simple diagrams | Clear contributor steps and branch rules | Open‑source projects, contributor guides, CI expectations | Reduces onboarding friction; clarifies PR targets and protections ⭐⭐⭐ |
| Architecture Diagrams for System Topology | Medium–High, complexity grows with system size | Medium, component inventory, cloud iconography | High‑level topology, dependency and risk visibility | System overviews, incident response, security reviews | Conveys system scope and external deps; helps debugging and design ⭐⭐⭐⭐ |
| Deployment Pipeline Diagrams for Release Cycles | Medium, multiple stages and gates to model | Medium, CI/CD configs, stage durations, approvals | Transparent release flow; documented gates and rollback paths | Release management, CI/CD documentation, publishing docs | Documents automation and approvals; reduces deployment errors ⭐⭐⭐ |
| Decision Tree Diagrams for Configuration and Setup Paths | Low–Medium, growth with branching depth | Low, content mapping and branching logic | Guided outcomes; fewer support tickets | Setup, troubleshooting, configuration selection | Personalizes docs and routes users to correct solutions ⭐⭐⭐ |
| Swimlane Diagrams for Cross‑Functional Workflows | Medium, many lanes can reduce readability | Medium, role/process mapping, team inputs | Clarified responsibilities and handoffs; identifies bottlenecks | Cross‑team processes, release workflows, triage | Highlights handoffs and SLAs; useful for process improvement ⭐⭐⭐ |
Bring Your Docs to Life with Mermaid
The biggest win from these Mermaid diagram examples isn’t prettier documentation. It’s operational discipline. When a diagram is plain text in the repository, it joins the same lifecycle as code, Markdown, and API definitions. People can review it in pull requests, diff it line by line, and update it without reopening a separate design tool. That changes behavior. Documentation stops feeling like a side project and starts behaving like part of the product.
That’s why Mermaid spread so effectively through developer ecosystems. Once platforms and documentation tools treated it as a native or near-native diagram layer, teams could write a diagram block directly in docs and let the renderer do the rest. The friction dropped. More important, maintenance friction dropped. That second part is what matters over time.
Each diagram type in this list solves a different class of documentation problem. Flowcharts clarify endpoint logic. Sequence diagrams expose hidden service choreography. Class diagrams map SDK shape. State diagrams prevent illegal lifecycle assumptions. ERDs explain your domain model. Git flow and deployment diagrams document how work moves through your team. Decision trees route users to the right setup path. Swimlanes reveal ownership across handoffs.
The trade-off is simplicity versus precision. Mermaid is great for durable, version-controlled diagrams. It isn’t always the best tool for freeform brainstorming or pixel-perfect layouts. If you’re trying to workshop ideas with non-technical stakeholders, a GUI whiteboard may still be better at the start. But once the process, model, or architecture stabilizes, moving that knowledge into Mermaid usually makes the documentation easier to maintain.
A second trade-off is renderer behavior. Not every Mermaid environment behaves exactly the same, and content with angle brackets or HTML-like text can trip rendering in real documentation systems. That’s why copy-paste examples shouldn’t stop at the happy path. Test diagrams in the renderer your users will see, not just in an editor preview. Keep labels plain. Escape risky text. Prefer documentation-safe patterns over clever syntax.
GitDocAI strengthens the whole approach because it closes the loop between source changes and published documentation. You can keep Mermaid blocks in Markdown or MDX, connect the repository, and let the platform regenerate affected pages as the codebase changes. Teams then review documentation updates as pending changes instead of discovering months later that an architecture page, auth flow, or state model no longer matches production. That’s how diagrams become living assets.
The simplest next step is the right one. Pick one page that already goes stale. A README, an auth guide, a webhook page, an SDK overview. Replace one static screenshot with one Mermaid block from this list. Commit it. Review it. Publish it. Once your team sees that the diagram can evolve in the same workflow as the code, the docs-as-code model starts to stick.
GitDocAI turns a GitHub repository into a branded documentation site that stays in sync with every commit. If you’re using Mermaid for docs-as-code, it’s a natural fit. Keep diagrams in Markdown or MDX, let GitDocAI detect changes, regenerate affected pages, and review updates before publishing. Explore GitDocAI if you want diagrams, API docs, internal docs, and help content to ship from the same source-controlled workflow.