Easily embed interactive Mermaid.js diagrams in your projects using simple iframes. No installation or configuration required - just use our hosted solution to render beautiful diagrams anywhere on the web.
graph TD
A[User's Website or App] -->|iframe embed| B[Mermaid Diagram Embed App]
B -->|Parses Mermaid code| C[Mermaid.js Renderer]
C -->|Renders SVG/PNG| D[Interactive Diagram Display]
D -->|Displayed in iframe| A
B -.->|API optional| C
- 🖼️ Easy iframe embedding for any Mermaid diagram
- 🎨 Supports all Mermaid diagram types (flowcharts, sequence, class, etc.)
- 🔍 Interactive diagrams with zoom and pan
- 🌓 Automatic theme detection (light/dark)
- ⚡ Fast, globally distributed CDN delivery
- 🔒 Secure sandboxed iframes
- 📱 Fully responsive designs
- 🎯 Zero configuration required
Embed any Mermaid diagram with a simple iframe:
<iframe
src="https://your-app-url.com/embed?code=YOUR_ENCODED_MERMAID_CODE"
width="100%"
height="500px"
style="border: 1px solid #e5e7eb; border-radius: 0.5rem;"
allowfullscreen
>
</iframe>
To properly include your Mermaid diagram in the URL, you'll need to URL-encode your Mermaid code. Here's how:
-
Start with your Mermaid code:
graph TD A[Start] --> B{Is it?} B -->|Yes| C[OK] C --> D[Rethink] D --> B B ---->|No| E[End]
-
Remove indentation and newlines (optional but recommended):
graph TD A[Start] --> B{Is it?} B -->|Yes| C[OK] C --> D[Rethink] D --> B B ---->|No| E[End]
-
URL-encode the string (JavaScript example):
const mermaidCode = 'graph TD A[Start] --> B{Is it?} B -->|Yes| C[OK] C --> D[Rethink] D --> B B ---->|No| E[End]'; const encoded = encodeURIComponent(mermaidCode); const url = `https://mermaid.brew.build/embed?code=${encoded}`;
-
Resulting URL:
https://your-app-url.com/embed?code=graph%20TD%20A%5BStart%5D%20--%3E%20B%7BIs%20it%3F%7D%20B%20--%3E%7CYes%7C%20C%5BOK%5D%20C%20--%3E%20D%5BRethink%5D%20D%20--%3E%20B%20B%20---%3E%7CNo%7C%20E%5BEnd%5D
code
: (Required) URL-encoded Mermaid diagram codetheme
: (Optional) Force light/dark theme (light
ordark
)width
: (Optional) Iframe width (e.g.,800px
or100%
)height
: (Optional) Iframe height (e.g.,600px
or100%
)
Example with all parameters:
https://your-app-url.com/embed?code=graph%20TD%20A%5BStart%5D%20--%3E%20B%5BEnd%5D&theme=dark&width=100%25&height=500px
If you prefer to host this yourself:
-
Clone the repository:
git clone https://github.com/your-username/mermaid-editor-v2.git cd mermaid-editor-v2
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Build for production:
npm run build npm start
GET /embed
- Main iframe endpointGET /api/diagram
- Raw diagram rendering API (returns SVG/PNG)POST /api/diagram
- Generate diagram from code (for server-side rendering)
- Mermaid.js - Powerful diagramming and charting
- Next.js - React Framework for server-side rendering
- React - UI Library
- TypeScript - Type Safety
- Tailwind CSS - Utility-first CSS
We welcome contributions! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue on our GitHub repository.
All diagrams are rendered client-side in the user's browser. Your diagram code is never stored on our servers.
- Mermaid.js for the amazing diagramming library
- Next.js for the awesome framework
- All our contributors who help improve this project
If you find this project useful, please consider giving it a ⭐️ on GitHub!