Mermaid — Generate Diagrams from Text Like Markdown
Mermaid is a JavaScript-based diagramming tool that renders Markdown-inspired text definitions to create diagrams and visualizations. Flowcharts, sequence diagrams, Gantt charts, class diagrams, ER diagrams, and more — all from plain text. Natively supported in GitHub Markdown.
Instalación lista para agent
Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.
npx -y tokrepo@latest install 90331916-3649-11f1-9bc6-00163e2b0d79 --target codexEjecutar después de confirmar el plan con dry-run.
What it is
Mermaid is a JavaScript-based diagramming tool that renders Markdown-inspired text definitions into diagrams and visualizations. It supports flowcharts, sequence diagrams, Gantt charts, class diagrams, ER diagrams, state diagrams, and more, all from plain text.
Mermaid is natively supported in GitHub Markdown, GitLab, Notion, Obsidian, and Docusaurus. It lets developers create documentation diagrams without Figma, draw.io, or any visual editor. Written in TypeScript with an MIT license.
How it saves time or tokens
Mermaid eliminates the context switch between writing documentation and creating diagrams. Instead of opening a separate tool, exporting images, and embedding them, you write diagram definitions inline with your documentation. Changes to diagrams are version-controlled alongside code. AI agents can generate and modify Mermaid diagrams as text, which is far more efficient than manipulating image files. The CLI tool renders diagrams to SVG or PNG for contexts that do not support live rendering.
How to use
- Write Mermaid diagrams directly in GitHub Markdown:
flowchart TD
A[User visits site] --> B{Logged in?}
B -->|Yes| C[Dashboard]
B -->|No| D[Login page]
D --> E[Enter credentials]
E --> B
- Use the CLI for rendering to files:
npm i -g @mermaid-js/mermaid-cli
mmdc -i input.mmd -o output.svg -t dark
mmdc -i input.mmd -o output.png -w 1200
- Embed in HTML for web applications:
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true, theme: 'dark' });
</script>
<pre class="mermaid">
sequenceDiagram
Client->>API: POST /login
API->>DB: SELECT user
DB-->>API: user record
API-->>Client: JWT token
</pre>
Example
An entity-relationship diagram for a project management system:
erDiagram
USER ||--o{ PROJECT : owns
PROJECT ||--|{ TASK : contains
TASK }o--|| USER : assigned_to
PROJECT ||--o{ MEMBER : has
USER ||--o{ MEMBER : participates
Related on TokRepo
- Documentation tools — More documentation and diagramming tools on TokRepo.
- Coding tools — Browse developer tools for AI-assisted workflows.
Common pitfalls
- Complex diagrams with many nodes and edges become unreadable. Break large diagrams into multiple smaller ones focused on specific subsystems.
- Not all Mermaid diagram types are supported in every platform. GitHub supports flowcharts, sequence, class, state, ER, Gantt, pie, and git graphs, but some newer types may lag.
- Using Mermaid's live editor for collaboration does not save state. Export diagram definitions to your repository for version control.
Preguntas frecuentes
Mermaid supports flowcharts (TD, LR, RL, BT), sequence diagrams, class diagrams, state diagrams, entity-relationship diagrams, Gantt charts, pie charts, git graphs, user journey maps, mindmaps, and timeline diagrams.
Yes. GitHub natively renders Mermaid code blocks in Markdown files including READMEs, issues, pull request descriptions, and wiki pages. Wrap your diagram in a mermaid-tagged code fence.
Yes. Since Mermaid diagrams are plain text, AI agents can generate, modify, and version them like any other code. This is more efficient than generating or editing image files.
Use the Mermaid CLI tool: npm i -g @mermaid-js/mermaid-cli, then mmdc -i input.mmd -o output.svg. The CLI supports SVG, PNG, and PDF output with configurable themes and dimensions.
Yes. Mermaid is open source under the MIT license. It is free for personal, commercial, and open-source use. The live editor at mermaid.live is also free.
Referencias (3)
- Mermaid GitHub— Mermaid is a JavaScript diagramming tool with 87K+ stars
- GitHub Blog— GitHub native Mermaid rendering support
- Mermaid Documentation— Mermaid live editor and documentation
Relacionados en TokRepo
Discusión
Activos relacionados
PlantUML — Generate UML Diagrams from Plain Text
A text-based diagramming tool that converts simple markup into sequence, class, activity, component, and many other UML and non-UML diagram types.
Kroki — Unified API for Diagrams as Code
A self-hosted service that renders diagrams from textual descriptions, supporting Mermaid, PlantUML, GraphViz, and 20+ formats.
Penrose — Create Beautiful Diagrams by Typing Math Notation
A system that automatically generates diagrams from plain-text mathematical notation using optimization-based layout.
FossFLOW — Beautiful Isometric Infrastructure Diagrams
Generate stunning isometric architecture diagrams from simple YAML definitions. Visualize cloud infrastructure, network topologies, and system designs with zero design skills required.