How to Add Mermaid.js Diagrams to Confluence
Learn how to embed Mermaid.js diagrams in Confluence using macros and third-party apps. Step-by-step instructions and real-world examples for technical teams.
Why Use Mermaid.js in Confluence?
Confluence is one of the most widely used documentation platforms in enterprise teams. Its built-in diagramming tools (Gliffy, Draw.io) create binary files that are hard to version-control, diff, or update without reopening a visual editor.
Mermaid.js changes that. Write plain text, get a rendered diagram. Updates take seconds, not minutes. And because the source is text, you can copy-paste it anywhere — GitHub, Notion, VS Code, your docs site.
This guide covers every method to add Mermaid diagrams to Confluence.
Method 1: Marketplace App (Confluence Cloud — Easiest)
For Confluence Cloud, the fastest path is a marketplace app. Search for "Mermaid" in the Atlassian Marketplace — several free and paid options are available.
Installation:
- Go to Confluence Settings → Find new apps
- Search for "Mermaid Diagrams" or "Markdown Macro"
- Install your chosen app
- On any page, insert
/mermaidor{mermaid}macro - Paste your Mermaid syntax
- Save — the diagram renders inline
Method 2: HTML Macro (Data Center / Server)
For Confluence Data Center or Server, use the HTML Macro (if your admin has enabled it). This loads Mermaid.js via CDN client-side.
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<div class="mermaid">
graph TD
A[Product Backlog] --> B[Sprint Planning]
B --> C[Sprint Execution]
C --> D[Sprint Review]
D --> E[Retrospective]
E --> B
</div>
<script>mermaid.initialize({ startOnLoad: true });</script>> The HTML macro must be enabled by a Confluence administrator.
Method 3: Export as Image (Universal Fallback)
Works in every Confluence version, no admin permission needed:
- Build your diagram at MermaidEditor.lol
- Export as PNG or SVG
- Upload the image to Confluence
- Add a collapsible code block with the raw Mermaid source for future edits
This gives you a visual diagram now, with the source preserved for later.
Real-World Examples
System Architecture
graph TB
subgraph Cloud
LB[Load Balancer]
subgraph App Tier
A1[API Server 1]
A2[API Server 2]
end
subgraph Data Tier
DB[(Primary DB)]
CACHE[Redis]
end
end
USERS[Users] --> LB
LB --> A1 & A2
A1 & A2 --> DB & CACHETry in Editor →Incident Response Flow
graph TD
ALERT[Alert Triggered] --> SEV{Severity?}
SEV -- P1/P2 --> PAGE[Page On-Call]
SEV -- P3/P4 --> TICKET[Create Ticket]
PAGE --> ACK[Acknowledge 15min]
ACK --> INV[Investigate]
INV --> RES{Resolved?}
RES -- Yes --> PIR[Post-Incident Review]
RES -- No --> ESC[Escalate to Lead]
ESC --> INV
PIR --> RUNBOOK[Update Runbook]Try in Editor →Agile Sprint States
stateDiagram-v2
[*] --> Backlog
Backlog --> InProgress : Sprint Start
InProgress --> InReview : Dev Complete
InReview --> Done : Approved
InReview --> InProgress : Changes Requested
Done --> [*]Try in Editor →Tips for Teams
- Create a Confluence template with placeholder Mermaid diagrams for common doc types (architecture, runbook, RFC)
- Always include source — even when using screenshots, add the Mermaid code in a collapsed section
- Name pages clearly — "Architecture: Payment Service v2" beats "Payment Diagram"
- Update diagrams in the same session as the system changes they describe
Conclusion
Mermaid.js brings diagrams-as-code to Confluence. Whether you use a marketplace macro, the HTML macro, or the screenshot workflow, your team can have clean, maintainable technical diagrams in the knowledge base.
The real win: diagrams become living documentation that evolves with your codebase.