Getting Started with Mermaid

Mermaid is a powerful diagramming and charting tool that uses text and code to generate diagrams. It's perfect for creating flowcharts, sequence diagrams, Gantt charts, and more.

What is Mermaid?

Mermaid lets you create diagrams and visualizations using text. It's widely used in documentation, README files, and technical documentation because it's easy to write, version-control friendly, and produces beautiful diagrams.

💡 Tip: All Mermaid diagrams start with a diagram type declaration (like graph TD or sequenceDiagram).

Basic Flowchart

Flowcharts are one of the most common diagram types. They show processes, decisions, and flows.

Simple Flowchart Example

graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Action 1]
    B -->|No| D[Action 2]
    C --> E[End]
    D --> E

Flowchart Syntax

Sequence Diagrams

Sequence diagrams show interactions between different components or actors over time.

Sequence Diagram Example

sequenceDiagram
    participant User
    participant Browser
    participant Server
    
    User->>Browser: Enter URL
    Browser->>Server: HTTP Request
    Server-->>Browser: HTML Response
    Browser-->>User: Display Page

Sequence Diagram Syntax

Class Diagrams

Class diagrams are used in object-oriented design to show classes, relationships, and inheritance.

Class Diagram Example

classDiagram
    class Animal {
        +String name
        +int age
        +makeSound()
    }
    class Dog {
        +String breed
        +bark()
    }
    class Cat {
        +String color
        +meow()
    }
    Animal <|-- Dog
    Animal <|-- Cat

Gantt Charts

Gantt charts are perfect for project planning and timeline visualization.

Gantt Chart Example

gantt
    title Project Timeline
    dateFormat YYYY-MM-DD
    section Planning
    Requirements    :a1, 2024-01-01, 30d
    Design         :a2, after a1, 20d
    section Development
    Backend        :a3, after a2, 40d
    Frontend       :a4, after a2, 35d

Converting Diagrams to Images

Once you've created your Mermaid diagram, you can easily convert it to various image formats.

Steps to Convert:

  1. Write or paste your Mermaid code in the editor
  2. See the live preview update in real-time
  3. Select your desired export format (PNG, JPG, PDF, or SVG)
  4. Click "Download Image" to save your diagram
💡 Pro Tip: SVG format is best for web use, PNG for presentations, and PDF for documents. JPG is great for smaller file sizes.

Best Practices

Common Issues and Solutions

Diagram not rendering?

Check for syntax errors. Common issues include:

Export not working?

Make sure: