# MermaidEditor full LLM index Canonical site: https://mermaideditor.lol MermaidEditor is an independent free online Mermaid.js editor for creating diagrams as code with instant preview, templates, tutorials, and export options. ## Core pages ### MermaidEditor — Free Online Mermaid.js Editor URL: https://mermaideditor.lol/ Free online Mermaid.js editor with instant browser preview, templates, tutorials, and PNG/SVG export. ### Mermaid Diagram Templates URL: https://mermaideditor.lol/templates Copy-paste Mermaid diagram templates for flowcharts, sequence diagrams, Gantt charts, class diagrams, ER diagrams, mindmaps, and more. ### Mermaid Syntax Cheat Sheet URL: https://mermaideditor.lol/cheat-sheet Quick reference for Mermaid.js diagram syntax and examples. ### About MermaidEditor URL: https://mermaideditor.lol/about About the MermaidEditor tool and its creator. ### Gagan Thakur URL: https://mermaideditor.lol/about/gagan-thakur Author and creator profile for MermaidEditor content. ### Contact MermaidEditor URL: https://mermaideditor.lol/contact Contact and support page for MermaidEditor. ## Blog tutorials and guides ### Mermaid Block Diagram Tutorial: Layouts & Examples URL: https://mermaideditor.lol/blog/mermaid-block-diagram-tutorial Published: 2026-05-01 Updated: 2026-05-01 Description: Learn the Mermaid.js block diagram syntax with copy-paste examples. Build system architecture, hardware layouts, and grid-based diagrams in plain text. # Mermaid Block Diagram Tutorial: Layouts, Arrows & Real Examples Mermaid's **block diagram** is one of the most underrated diagram types in the library. Introduced in Mermaid 10.9, it lets you arrange rectangular blocks in flexible grid layouts — perfect for system architecture, hardware schematics, memory maps, network zones, and any "boxes-and-lines" picture that doesn't fit neatly into a flowchart. If you've ever fought with a flowchart trying to make it look like a *layout* instead of a *flow*, this is the diagram type you've been missing. ## What Is a Mermaid Block Diagram? A block diagram is a grid of blocks (rectangles) connected by arrows. Unlike flowcharts, blocks don't try to auto-layout based on connections — **you control the columns and rows directly**. That makes them ideal for diagrams where the *spatial arrangement itself* carries meaning, like: - Microservice architectures - CPU / memory / hardware layouts - Network DMZ and security zones - UI wireframes and dashboard regions - Cloud account / VPC topologies ## Basic Syntax Every block diagram starts with the `block-beta` keyword: ```mermaid block-beta columns 3 A B C D E F ``` That single `columns 3` declaration is the magic. It tells Mermaid to lay out everything in a 3-wide grid. Add more identifiers, and they wrap into new rows automatically. ## Block Shapes Just like flowcharts, blocks support multiple shapes via bracket syntax: ```mermaid block-beta columns 4 A["Rectangle"] B("Rounded") C(("Circle")) D{"Diamond"} E[("Cylinder")] F>"Flag"] G{{"Hexagon"}} H[/"Parallelogram"/] ``` | Syntax | Shape | |--------|-------| | `A["text"]` | Rectangle | | `A("text")` | Rounded rectangle | | `A(("text"))` | Circle | | `A{"text"}` | Diamond | | `A[("text")]` | Cylinder | | `A{{"text"}}` | Hexagon | ## Spanning Columns and Rows This is where block diagrams pull ahead of flowcharts. Use `block:id:width` to make a block span multiple columns: ```mermaid block-beta columns 3 Header["Application Header"]:3 Sidebar["Sidebar"] Main["Main Content"]:2 Footer["Footer"]:3 ``` That single diagram is a complete page layout in five lines of text. Try doing *that* cleanly in a flowchart. ## Composite Blocks (Nested Groups) Use the `block:groupName` syntax to create a container that holds other blocks: ```mermaid block-beta columns 3 block:Frontend Web["Web App"] Mobile["Mobile App"] end API["API Gateway"] block:Backend Auth["Auth Service"] Users["User Service"] Orders["Order Service"] end ``` Nested groups render as labeled containers with their children inside — exactly what you want for microservice or domain-driven architecture diagrams. ## Adding Arrows Connections work the same way they do in flowcharts: ```mermaid block-beta columns 3 A["Client"] space B["Load Balancer"] space C["Server"] A --> B B --> C ``` The `space` keyword inserts an empty cell so arrows have room to breathe. Use `space:2` to skip multiple cells. ## Styling Blocks Block diagrams support the same `style` and `classDef` keywords as flowcharts: ```mermaid block-beta columns 3 A["Critical"] B["Healthy"] C["Warning"] style A fill:#ef4444,color:#fff,stroke:#991b1b style B fill:#22c55e,color:#fff,stroke:#15803d style C fill:#f59e0b,color:#fff,stroke:#b45309 ``` For repeated styles, define a class once and reuse it: ```mermaid block-beta columns 4 classDef service fill:#3b82f6,color:#fff,stroke:#1d4ed8 Web Auth Users Orders class Web,Auth,Users,Orders service ``` ## Real-World Example: AWS Architecture Here's a production-style cloud architecture in Mermaid block syntax: ```mermaid block-beta columns 5 block:Edge:5 CF["CloudFront CDN"] WAF["WAF"] R53["Route 53"] end ALB["Application Load Balancer"]:5 block:Compute:3 ECS1["ECS Task 1"] ECS2["ECS Task 2"] ECS3["ECS Task 3"] end block:Cache:2 Redis["ElastiCache"] Mem["Memcached"] end RDS["RDS Postgres (Multi-AZ)"]:3 S3["S3 Bucket"]:2 ``` Five rows, real components, zero drag-and-drop. And because it's plain text, you can diff it in pull requests, generate it programmatically, or paste it into a GitHub README and it just renders. ## When to Use Block Diagrams vs Flowcharts | Use a **block diagram** when... | Use a **flowchart** when... | |---------------------------------|------------------------------| | Layout itself carries meaning | Flow / sequence is the point | | You're drawing system architecture | You're drawing a process | | You want exact column control | You want auto-layout | | Diagram represents *space* (zones, regions) | Diagram represents *time* (steps) | ## Common Pitfalls - **Forgetting `columns N`** — without it, blocks stack vertically. Always declare your grid width. - **Spans that exceed columns** — `X:5` in a 3-column grid silently breaks layout. Match your spans to your grid. - **Old Mermaid version** — block diagrams need Mermaid **10.9 or newer**. If they don't render, upgrade your renderer (GitHub, Notion, and most modern tools already support them). - **Nested arrows** — arrows between blocks inside different `block:` groups work, but routing can get messy. Keep critical arrows at the top level. ## Conclusion Block diagrams fill the exact gap that flowcharts and ER diagrams leave open: **layout-first visualizations**. Once you've drawn one architecture diagram in `block-beta` syntax, you'll wonder why you ever opened Lucidchart for the same job. The whole syntax fits on a sticky note: `columns N`, blocks, optional spans with `:N`, and `block:group...end` for nesting. That's it. Everything else is the same Mermaid you already know. [Try the Mermaid block diagram syntax in our free editor →](/) ### Mermaid Flowchart Styling: Colors, Classes & Themes URL: https://mermaideditor.lol/blog/mermaid-flowchart-styling-guide Published: 2026-07-23 Updated: 2026-07-23 Description: Master Mermaid.js flowchart styling with inline styles, CSS classes, custom themes, and color schemes. Complete guide with copy-paste examples. # Mermaid.js Flowchart Styling: Colors, Classes & Custom Themes Mermaid.js flowcharts look decent out of the box, but real-world documentation demands custom styling — branded colors, highlighted paths, status indicators, and readable layouts. This guide covers every styling technique available in Mermaid.js flowcharts, from inline styles to reusable CSS classes and full theme customization. ## Why Style Your Mermaid Flowcharts? Default Mermaid diagrams use a generic color palette. Custom styling helps you: - **Highlight critical paths** in workflows - **Match brand guidelines** in documentation - **Indicate status** (success, failure, pending) with color coding - **Improve readability** for complex diagrams - **Create professional documentation** that stands out ## Inline Styles with `style` Keyword The simplest way to style individual nodes is the `style` keyword. Apply it after defining your flowchart: ```mermaid flowchart LR A[Start] --> B[Process] B --> C[End] style A fill:#4CAF50,stroke:#333,stroke-width:2px,color:#fff style B fill:#2196F3,stroke:#333,stroke-width:2px,color:#fff style C fill:#f44336,stroke:#333,stroke-width:2px,color:#fff ``` Available style properties: | Property | Description | Example | |----------|-------------|---------| | `fill` | Background color | `fill:#4CAF50` | | `stroke` | Border color | `stroke:#333` | | `stroke-width` | Border thickness | `stroke-width:2px` | | `color` | Text color | `color:#fff` | | `stroke-dasharray` | Dashed border | `stroke-dasharray:5 5` | | `opacity` | Transparency | `opacity:0.8` | ## Reusable Styles with `classDef` For diagrams with many nodes, inline styles get repetitive. Use `classDef` to define reusable style classes, then apply them with `:::className` or the `class` keyword: ```mermaid flowchart TD A[Deploy to Staging]:::success --> B{Tests Pass?} B -->|Yes| C[Deploy to Prod]:::success B -->|No| D[Rollback]:::danger D --> E[Fix & Retry]:::warning E --> A classDef success fill:#4CAF50,stroke:#2E7D32,color:#fff classDef danger fill:#f44336,stroke:#c62828,color:#fff classDef warning fill:#FF9800,stroke:#E65100,color:#fff ``` You can also assign classes to multiple nodes at once: ```mermaid flowchart LR A[Step 1] --> B[Step 2] --> C[Step 3] D[Step 4] --> E[Step 5] class A,B,C active class D,E inactive classDef active fill:#1a73e8,stroke:#174ea6,color:#fff classDef inactive fill:#e8eaed,stroke:#9aa0a6,color:#5f6368 ``` ## Styling Links (Edges) You can style the connections between nodes using `linkStyle`. Links are zero-indexed in the order they appear: ```mermaid flowchart LR A --> B --> C --> D linkStyle 0 stroke:#f44336,stroke-width:3px linkStyle 1 stroke:#4CAF50,stroke-width:3px linkStyle 2 stroke:#2196F3,stroke-width:3px,stroke-dasharray:5 5 ``` To style all links at once: ```mermaid flowchart LR A --> B --> C linkStyle default stroke:#999,stroke-width:2px ``` ## Real-World Example: Styled Architecture Diagram Here is a practical example showing a microservices architecture with color-coded layers: ```mermaid flowchart TB subgraph Client Layer A[Web App]:::frontend B[Mobile App]:::frontend end subgraph API Layer C[API Gateway]:::api D[Auth Service]:::api end subgraph Services E[User Service]:::service F[Order Service]:::service G[Payment Service]:::service end subgraph Data Layer H[(PostgreSQL)]:::database I[(Redis Cache)]:::cache end A & B --> C C --> D C --> E & F & G E & F --> H G --> H C --> I classDef frontend fill:#42A5F5,stroke:#1565C0,color:#fff classDef api fill:#66BB6A,stroke:#2E7D32,color:#fff classDef service fill:#FFA726,stroke:#E65100,color:#fff classDef database fill:#AB47BC,stroke:#6A1B9A,color:#fff classDef cache fill:#EF5350,stroke:#C62828,color:#fff ``` This pattern makes complex architectures instantly readable by separating concerns visually. ## Subgraph Styling You can also style subgraphs to create visual groupings: ```mermaid flowchart TB subgraph production["Production Environment"] A[Load Balancer] --> B[App Server 1] A --> C[App Server 2] end subgraph staging["Staging Environment"] D[Staging Server] end D -->|promote| A style production fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px style staging fill:#FFF3E0,stroke:#FF9800,stroke-width:2px ``` ## Theme Configuration with `init` For global styling across the entire diagram, use the `init` directive to configure the theme: ```mermaid %%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#1a73e8', 'primaryTextColor': '#fff', 'primaryBorderColor': '#174ea6', 'lineColor': '#5f6368', 'secondaryColor': '#e8f0fe', 'tertiaryColor': '#f1f3f4'}}}%% flowchart TD A[Start] --> B[Process 1] B --> C[Process 2] C --> D[End] ``` Built-in themes you can use: - **default** — Standard Mermaid colors - **dark** — Dark background with light text - **forest** — Green-themed - **neutral** — Grayscale, great for printing - **base** — Minimal, best for custom `themeVariables` ## Tips for Better Styled Diagrams 1. **Limit your palette** — Use 3-5 colors maximum. Too many colors create visual noise. 2. **Use semantic colors** — Green for success, red for errors, blue for information. Your readers already know these conventions. 3. **Style subgraphs with soft fills** — Use light background colors (`#E8F5E9`) for subgraphs so node colors remain prominent. 4. **Consistent stroke widths** — Pick one stroke width and stick with it unless highlighting specific paths. 5. **Test in dark mode** — If your docs support dark mode, verify your color choices work on both backgrounds. ## Try It in the Mermaid Editor Experimenting with styles is easiest in a live editor. Head over to [Mermaid Editor](https://mermaideditor.lol) to paste any of these examples, tweak the colors, and see instant results. The live preview makes it simple to fine-tune your palette before embedding diagrams in your documentation. ## Conclusion Mermaid.js flowchart styling transforms basic diagrams into professional, readable documentation. Start with `classDef` for reusable styles, use `linkStyle` for edge customization, and leverage themes for global consistency. Whether you are documenting CI/CD pipelines, microservices, or business workflows, proper styling makes your diagrams significantly more effective. ### How to Create CI/CD Pipeline Diagrams with Mermaid.js URL: https://mermaideditor.lol/blog/mermaid-cicd-pipeline-diagram Published: 2026-04-14 Updated: 2026-04-14 Description: Learn how to visualize CI/CD pipelines using Mermaid.js. Step-by-step examples for GitHub Actions, GitLab CI, Jenkins, and deployment workflows. # How to Create CI/CD Pipeline Diagrams with Mermaid.js CI/CD pipelines are the backbone of modern software delivery. But explaining a pipeline to a new team member or documenting it for an architecture review? That's where a clear diagram beats a wall of YAML every time. Mermaid.js lets you create CI/CD pipeline diagrams as code — no drag-and-drop tools, no image files to keep updated. Just text that lives alongside your pipeline config. In this guide, you'll learn how to diagram real-world CI/CD workflows using Mermaid flowcharts, sequence diagrams, and more. ## Why Diagram Your CI/CD Pipeline? Pipeline configs (GitHub Actions YAML, Jenkinsfiles, .gitlab-ci.yml) describe *what* happens, but they're hard to scan visually. A diagram answers questions instantly: - What runs in parallel vs. sequentially? - Where are the approval gates? - What happens on failure? - Which environments get deployed to? Mermaid diagrams stay in sync because they live in your repo — right next to the pipeline config they describe. ## Basic CI/CD Pipeline Flowchart Let's start with a simple build-test-deploy pipeline: ```mermaid graph LR A[Push to main] --> B[Build] B --> C[Unit Tests] C --> D[Integration Tests] D --> E[Deploy to Staging] E --> F{Manual Approval} F -->|Approved| G[Deploy to Production] F -->|Rejected| H[Rollback] ``` This gives you a left-to-right flow that anyone can understand at a glance. The diamond shape for manual approval makes the decision point obvious. ## Parallel Stages with Subgraphs Real pipelines run jobs in parallel. Mermaid subgraphs are perfect for grouping parallel stages: ```mermaid graph TD A[Code Push] --> B[Build Docker Image] B --> C[Push to Registry] C --> D[Run Tests] subgraph Tests [Parallel Test Suite] D --> E[Unit Tests] D --> F[E2E Tests] D --> G[Security Scan] D --> H[Lint & Format] end E --> I[All Passed?] F --> I G --> I H --> I I -->|Yes| J[Deploy Staging] I -->|No| K[Notify Team] ``` The subgraph labeled "Parallel Test Suite" visually groups the jobs that run concurrently, making it clear which steps block deployment. ## GitHub Actions Workflow Diagram Here's how to diagram a typical GitHub Actions workflow with multiple jobs: ```mermaid graph TD A[PR Opened] --> B[Lint Job] A --> C[Test Job] A --> D[Build Job] B --> E{All Checks Pass?} C --> E D --> E E -->|Yes| F[Merge to main] F --> G[Build & Push Image] G --> H[Deploy to EKS Staging] H --> I[Run Smoke Tests] I -->|Pass| J[Deploy to EKS Production] I -->|Fail| K[Alert on Slack] ``` This maps directly to how GitHub Actions jobs depend on each other, making it easy to compare the diagram against your workflow YAML. ## GitLab CI Pipeline Stages GitLab CI pipelines are organized in stages. Here's a multi-stage deployment diagram: ```mermaid graph LR subgraph Build Stage A[compile] --> B[docker-build] end subgraph Test Stage C[unit-test] D[sast-scan] E[dependency-check] end subgraph Deploy Stage F[deploy-staging] G[deploy-production] end B --> C B --> D B --> E C --> F D --> F E --> F F --> G ``` Each subgraph maps to a GitLab CI stage, and the arrows show job dependencies — exactly matching the `needs:` keyword in your `.gitlab-ci.yml`. ## Deployment Pipeline with Rollback For production deployments, you need to show the rollback path: ```mermaid graph TD A[Release Tagged] --> B[Build Artifacts] B --> C[Deploy to Canary 5%] C --> D{Metrics OK?} D -->|Yes| E[Roll out to 25%] E --> F{Metrics OK?} F -->|Yes| G[Roll out to 100%] F -->|No| H[Rollback to Previous] D -->|No| H H --> I[Post-mortem] G --> J[Monitor 24h] ``` This canary deployment diagram shows progressive rollout percentages and the rollback path — critical for communicating deployment strategy to stakeholders. ## Sequence Diagram for Deployment Approval Sometimes a sequence diagram better captures the interaction between people and systems: ```mermaid sequenceDiagram participant Dev as Developer participant CI as CI Server participant QA as QA Team participant Prod as Production Dev->>CI: Push to release branch CI->>CI: Build & Test CI->>QA: Deploy to staging QA->>QA: Run acceptance tests QA->>Dev: Approve / Request changes Dev->>CI: Trigger production deploy CI->>Prod: Blue-green deployment Prod->>CI: Health check OK CI->>Dev: Deployment successful ``` This shows who is involved at each stage — useful for runbooks and on-call documentation. ## Styling Your Pipeline Diagrams Make critical paths and failure states stand out with Mermaid styling: ```mermaid graph LR A[Build] --> B[Test] B --> C[Deploy] C --> D[Production Live] B --> E[Failed] style D fill:#22c55e,stroke:#16a34a,color:#fff style E fill:#ef4444,stroke:#dc2626,color:#fff style A fill:#3b82f6,stroke:#2563eb,color:#fff ``` Green for success, red for failure, blue for in-progress — your team will instantly understand the pipeline state. ## Best Practices for CI/CD Diagrams 1. **Keep it high-level** — Don't diagram every shell command. Focus on stages and decision points. 2. **Use subgraphs for parallel work** — Group concurrent jobs visually. 3. **Show the unhappy path** — Rollbacks, failures, and alerts are just as important as the happy path. 4. **Put diagrams in your README** — GitHub and GitLab both render Mermaid natively in markdown. 5. **Update with the pipeline** — When you change your CI config, update the diagram in the same PR. ## Where to Use These Diagrams - **README.md** — GitHub and GitLab render Mermaid automatically - **Architecture Decision Records (ADRs)** — Document why your pipeline works this way - **Onboarding docs** — New engineers understand the deploy process in seconds - **Incident runbooks** — Show the rollback path clearly ## Conclusion Mermaid.js turns CI/CD pipeline documentation from a chore into something that actually stays maintained. Because the diagram is text, it can be reviewed in PRs, diffed, and updated alongside the pipeline config it describes. Start with a simple flowchart of your main pipeline, then expand to cover parallel stages, approval gates, and rollback paths. [Create your CI/CD pipeline diagram now →](/) ### Mermaid.js Quadrant Chart: Complete Guide with Examples URL: https://mermaideditor.lol/blog/mermaid-quadrant-chart-guide Published: 2026-04-10 Updated: 2026-04-10 Description: Learn how to create quadrant charts in Mermaid.js for prioritization, risk analysis, and strategic planning. Includes syntax, examples, and best practices. # Mermaid.js Quadrant Chart: Complete Guide with Examples Quadrant charts are one of the most powerful yet underused diagram types in Mermaid.js. They let you plot items across two axes to visualize priorities, risks, strategies, and trade-offs — all with simple text-based syntax. In this guide, you'll learn everything about creating **Mermaid quadrant charts**, from basic syntax to real-world examples you can use today. ## What Is a Quadrant Chart? A quadrant chart divides a two-dimensional space into four sections using two axes. Each quadrant represents a different category or priority level. You've probably seen them used as: - **Eisenhower Matrix** (urgent vs. important) - **BCG Matrix** (market growth vs. market share) - **Risk Matrix** (likelihood vs. impact) - **Feature Prioritization** (effort vs. value) Mermaid.js makes it easy to create these charts with plain text, no drag-and-drop tools required. ## Basic Mermaid Quadrant Chart Syntax Here's the simplest quadrant chart you can create in Mermaid.js: ```mermaid quadrantChart title Feature Prioritization x-axis Low Effort --> High Effort y-axis Low Value --> High Value quadrant-1 Do First quadrant-2 Plan Carefully quadrant-3 Quick Wins quadrant-4 Deprioritize Feature A: [0.8, 0.9] Feature B: [0.2, 0.8] Feature C: [0.7, 0.3] Feature D: [0.3, 0.2] ``` Let's break down the syntax: - **`quadrantChart`** — declares the diagram type - **`title`** — sets the chart title - **`x-axis`** and **`y-axis`** — define axis labels with direction (low → high) - **`quadrant-1`** through **`quadrant-4`** — label each quadrant (numbered top-right, top-left, bottom-left, bottom-right) - **Data points** — each item has a name and `[x, y]` coordinates between 0 and 1 ## Understanding Quadrant Numbering The quadrant numbering in Mermaid.js follows a specific order that's important to understand: | Quadrant | Position | Typical Use | |----------|----------|-------------| | quadrant-1 | Top-Right | High priority / best outcome | | quadrant-2 | Top-Left | High on Y, low on X | | quadrant-3 | Bottom-Left | Lowest priority | | quadrant-4 | Bottom-Right | High on X, low on Y | This numbering follows mathematical convention (counter-clockwise from top-right), so keep it in mind when labeling your quadrants. ## Real-World Mermaid Quadrant Chart Examples ### 1. Eisenhower Priority Matrix The Eisenhower Matrix is perfect for task management and personal productivity: ```mermaid quadrantChart title Eisenhower Matrix x-axis Not Urgent --> Urgent y-axis Not Important --> Important quadrant-1 Do It Now quadrant-2 Schedule It quadrant-3 Eliminate quadrant-4 Delegate Crisis meeting: [0.9, 0.9] Strategic planning: [0.2, 0.85] Email replies: [0.75, 0.2] Social media: [0.15, 0.1] Code review: [0.6, 0.7] Documentation: [0.3, 0.6] ``` This example plots common work tasks across urgency and importance, making it instantly clear what to focus on. ### 2. Technology Risk Assessment Use a quadrant chart to evaluate technology risks in your architecture: ```mermaid quadrantChart title Tech Risk Assessment x-axis Low Likelihood --> High Likelihood y-axis Low Impact --> High Impact quadrant-1 Critical Risk quadrant-2 Monitor Closely quadrant-3 Accept quadrant-4 Mitigate Database failure: [0.3, 0.95] API rate limiting: [0.7, 0.5] CSS regression: [0.6, 0.15] Auth provider outage: [0.2, 0.8] Memory leak: [0.5, 0.7] Typo in config: [0.8, 0.1] ``` ### 3. Product Feature Effort-Impact Matrix Product managers love this one for sprint planning: ```mermaid quadrantChart title Sprint Planning Matrix x-axis Low Effort --> High Effort y-axis Low Impact --> High Impact quadrant-1 Major Projects quadrant-2 Quick Wins quadrant-3 Fill-Ins quadrant-4 Thankless Tasks Dark mode: [0.4, 0.85] Search feature: [0.85, 0.9] Fix typos: [0.1, 0.15] Refactor auth: [0.9, 0.4] Add tooltips: [0.2, 0.5] Export to PDF: [0.6, 0.75] ``` ## Tips for Better Quadrant Charts ### 1. Choose Meaningful Axes Your axes should represent two independent dimensions that create meaningful quadrants. Common axis pairs include: - Effort vs. Value - Risk vs. Reward - Urgency vs. Importance - Cost vs. Benefit - Feasibility vs. Desirability ### 2. Position Points Carefully Coordinates range from 0 to 1. Use the full range to spread your data points and avoid clustering them in one area. Items near quadrant boundaries signal areas that need discussion. ### 3. Keep It Focused Quadrant charts work best with 4–12 data points. Too many items create visual clutter and defeat the purpose of prioritization. ### 4. Use Descriptive Labels Quadrant labels should immediately communicate the action or category. "Do First" is better than "Q1". "Eliminate" is better than "Low-Low". ## Mermaid Quadrant Chart vs. Other Tools Why use Mermaid.js for quadrant charts instead of Excel, Google Sheets, or dedicated tools? - **Version control** — Mermaid charts live in your codebase and are tracked by Git - **Documentation-as-code** — embed charts directly in Markdown files, READMEs, and wikis - **No vendor lock-in** — plain text means you own your diagrams forever - **Fast iteration** — change a number and the chart updates instantly - **Works everywhere** — GitHub, GitLab, Notion, Obsidian, VS Code, and [online editors like MermaidEditor.lol](https://mermaideditor.lol) ## Try It in the Online Editor The fastest way to experiment with Mermaid quadrant charts is to use an online editor. At [MermaidEditor.lol](https://mermaideditor.lol), you can: - Write your quadrant chart syntax with live preview - Export diagrams as PNG or SVG - Share your charts with a link - Access templates to get started quickly Paste any of the examples from this guide into the editor and start customizing them for your own use case. ## Common Mistakes to Avoid 1. **Forgetting the coordinate brackets** — data points need `[x, y]` format 2. **Mixing up quadrant numbers** — remember, numbering starts top-right and goes counter-clockwise 3. **Using coordinates outside 0–1** — Mermaid only accepts values between 0 and 1 4. **Overcrowding the chart** — if you have more than 12 items, consider splitting into multiple charts ## Conclusion Mermaid.js quadrant charts are a simple but powerful way to visualize two-dimensional comparisons. Whether you're prioritizing features, assessing risks, or planning your sprint, the text-based syntax makes it easy to create, update, and share these diagrams. Ready to create your first quadrant chart? Head over to [MermaidEditor.lol](https://mermaideditor.lol) and start building. ### How to Create Timeline Diagrams with Mermaid.js URL: https://mermaideditor.lol/blog/mermaid-timeline-diagram Published: 2026-04-07 Updated: 2026-05-27 Description: Learn how to create mermaid timeline diagrams with simple text syntax. Includes real-world examples for project roadmaps, historical events, and release schedules. ## What Is a Mermaid Timeline Diagram? A **mermaid timeline diagram** lets you visualize events, milestones, and phases in chronological order — using nothing but text. No drag-and-drop tools, no image editing, no external software. Just write the syntax, and Mermaid renders a clean, shareable timeline. Timeline diagrams are perfect for: - Product roadmaps and release schedules - Historical events and project retrospectives - Onboarding docs showing company or project history - Sprint planning visuals embedded in your README In this guide you'll learn the complete Mermaid timeline syntax, see multiple real-world examples, and pick up tips for writing timelines that are easy to maintain. ## Basic Mermaid Timeline Syntax The timeline diagram type was introduced in Mermaid v9.4. The core structure is straightforward: ```mermaid timeline title History of Mermaid.js 2014 : Knut Sveidqvist releases Mermaid on GitHub 2016 : First major adoption in developer docs 2019 : GitHub integration discussions begin 2022 : GitHub natively renders Mermaid in Markdown 2023 : Mermaid v10 released with major improvements 2024 : Over 60,000 GitHub stars ``` Breaking down the syntax: - **`timeline`** — declares the diagram type - **`title`** — optional chart title displayed at the top - **`2014 : Event text`** — a time period followed by `:` and the event label Multiple events can share the same time period by adding more lines with the same period label. ## Adding Multiple Events Per Period One of the most useful features is grouping multiple events under a single time label: ```mermaid timeline title 2025 Product Roadmap Q1 : Launch beta : Onboard first 100 users : Set up analytics Q2 : Public launch : Email campaign Q3 : Mobile app release : Paid tier introduced Q4 : Enterprise plan : Partner integrations ``` Each additional `: event` line (indented, without repeating the period) is added to that period's column. This keeps related events grouped without cluttering the timeline axis. ## Sections — Adding Colour-Coded Groups For longer timelines, you can organise periods into named sections. Each section gets its own colour in the rendered diagram: ```mermaid timeline title Company Growth Timeline section Early Stage 2020 : Company founded : Seed funding ($500K) 2021 : First product shipped : 5-person team section Growth Stage 2022 : Series A ($3M) : 20-person team : First enterprise customer 2023 : Product line expanded : Reached profitability section Scale Stage 2024 : Series B ($15M) : 80-person team 2025 : International expansion : IPO preparation ``` Sections are declared with `section Name` and apply to all subsequent periods until another section is declared. They're great for separating phases of a project, company lifecycle stages, or sprint cycles. ## Real-World Example: Software Release History Here's a mermaid timeline diagram documenting a product's version history — a common use case for developer docs and README files: ```mermaid timeline title My App — Release History section Alpha v0.1 : Core authentication : Basic CRUD operations v0.2 : REST API stabilised : Unit tests added section Beta v0.5 : Public beta launched : Dashboard UI : Email notifications v0.9 : Performance optimisations : Bug fixes from beta feedback section Production v1.0 : General availability : Stripe payments integrated v1.1 : Team collaboration features v2.0 : Real-time sync : Mobile app (iOS + Android) ``` Because the source is plain text, this lives right in your repo. When you ship v2.1, you add two lines — no image exports needed. ## Example: Project Sprint Timeline Timeline diagrams also work well for sprint planning or retrospective documentation: ```mermaid timeline title Q1 Sprint Overview section Sprint 1 (Jan) Week 1 : Kick-off and backlog grooming : Environment setup Week 2 : User auth module Week 3 : Profile management Week 4 : Sprint review and demo section Sprint 2 (Feb) Week 5 : Dashboard v1 : API rate limiting Week 6 : Notifications service Week 7 : Data export feature Week 8 : Sprint review section Sprint 3 (Mar) Week 9 : Mobile-responsive UI Week 10 : Performance profiling Week 11 : Load testing Week 12 : Q1 retrospective ``` ## Example: Historical Technology Timeline Mermaid timeline diagrams aren't just for software projects. They're equally useful for educational content, articles, and documentation that places events in historical context: ```mermaid timeline title Key Moments in Web Development section Web 1.0 1991 : Tim Berners-Lee publishes the first website 1994 : Netscape Navigator launches 1995 : JavaScript created by Brendan Eich : Java applets introduced 1996 : CSS 1 specification released section Web 2.0 2004 : Gmail launches, proving rich web apps are possible 2005 : AJAX popularised by Google Maps : YouTube founded 2006 : jQuery released 2008 : V8 JavaScript engine by Google 2009 : Node.js created by Ryan Dahl section Modern Web 2013 : React released by Facebook 2014 : Vue.js introduced 2016 : Angular 2 released 2017 : WebAssembly becomes a W3C recommendation draft 2020 : Deno 1.0 released 2022 : Bun JavaScript runtime released ``` ## Embedding Timelines in Your Docs Mermaid timeline diagrams render natively in **GitHub Markdown** (wrap in a `mermaid` code fence), **Notion** (paste using the Mermaid block), **Obsidian**, **Docusaurus**, **MkDocs**, and anywhere Mermaid is supported. For GitHub specifically: ``` ```mermaid timeline title My Project Milestones 2024 : MVP shipped 2025 : 1,000 users ``` ``` You can also try and iterate on your timeline syntax in the [Mermaid Live Editor](https://mermaideditor.lol) before committing — it gives instant visual feedback as you type, so you can see how sections and event groupings look before they go into your docs. ## Mermaid Timeline vs Gantt Chart Mermaid offers two diagram types that handle time-based content differently: | Feature | Timeline | Gantt Chart | |---|---|---| | Purpose | Events and milestones | Task durations and schedules | | Shows duration | No | Yes | | Dependencies | No | Yes | | Best for | History, roadmaps, retrospectives | Project planning, scheduling | | Syntax complexity | Simple | Moderate | If you need to show **how long** tasks take, use a Gantt chart. If you want to place **events and milestones** in chronological context, use a timeline diagram. ## Tips for Better Timeline Diagrams **Keep event labels short.** The timeline renders each event as a chip inside a column. Long text wraps awkwardly. Aim for 3-6 words per event. **Use consistent period granularity.** Mixing `Q1 2024` with `Week 3` in the same diagram looks messy. Pick a granularity (quarters, months, sprints) and stick to it. **Use sections for long timelines.** Anything with more than 6-8 periods benefits from section groupings — they add colour contrast and logical separation. **Put the most important events first in a period.** Mermaid displays events top-to-bottom within a period column. Lead with the headline event. **Test in the live editor first.** Before adding a timeline to your repo's README or docs, paste it into [mermaideditor.lol](https://mermaideditor.lol) to see how it renders. Easier to tweak there than after pushing a commit. ## Troubleshooting Common Issues **Timeline not rendering?** Check that you're on Mermaid v9.4+. GitHub, Notion, and most modern integrations are already there, but self-hosted tools may lag behind. **Events appearing in wrong order?** Mermaid renders periods in the order they appear in the source — there's no automatic date sorting. Write them top-to-bottom in chronological order. **Text overflowing?** Shorten event labels or split into multiple sections. **Section colours look off in dark mode?** Mermaid's built-in themes handle dark mode differently. Use the `dark` or `default` theme directive at the top of your diagram if needed. ## Conclusion Mermaid timeline diagrams are a quick, maintainable way to visualise chronological information in your documentation. The syntax is minimal, the output is clean, and because diagrams live as text in your repo, they stay up-to-date as your project evolves. Start with a simple 4-5 period timeline, add sections when it grows, and you'll have professional-looking roadmap and history diagrams without ever opening a design tool. [Try building your timeline diagram for free at mermaideditor.lol →](/) ## Additional Guide: How to Use Mermaid Timeline Diagrams: Complete Instructions Guide (2026) Mermaid timelines are one of the most underused features in the library. Everyone knows flowcharts and sequence diagrams — but timelines? They're clean, readable, and perfect for project overviews, research plans, and historical summaries. This guide covers everything: the full syntax, sections, multi-line events, and real working examples you can copy and run immediately. ## What Is a Mermaid Timeline? A Mermaid timeline (`timeline` diagram type) lets you map events to time periods using plain text. You define time sections, then list events under each one. Mermaid renders it as a horizontal or vertical visual timeline. It's different from a Gantt chart. Gantt tracks duration and dependencies. A timeline is simpler — it's a chronological story. **When to use it:** - Project milestone overviews - Product roadmaps - Research planning (phases of a study) - Historical event summaries - Onboarding sequences ## Basic Syntax — Your First Timeline Here's the minimal structure: ```mermaid timeline title My Project Timeline section Phase 1 Kick-off meeting : 2026-01-01 Requirements done : 2026-01-15 section Phase 2 Design complete : 2026-02-01 Dev complete : 2026-03-01 ``` **What this does:** Creates a timeline with two sections (Phase 1 and Phase 2), each with two events. The colon separates the event label from the date. Key rules: - `timeline` keyword starts the diagram - `title` is optional but recommended - `section` groups related events - Each event: `Event label : date-or-period` ## Understanding Sections Sections are the backbone of Mermaid timelines. They create visual groupings that help readers scan the timeline at a glance. ```mermaid timeline title Software Release History section 2024 v1.0 Launch : Jan 2024 v1.1 Bug fixes : Mar 2024 v1.2 New features : Jun 2024 section 2025 v2.0 Major rewrite : Jan 2025 v2.1 Performance : Apr 2025 section 2026 v3.0 AI features : Feb 2026 v3.1 Mobile app : May 2026 ``` **What this does:** Maps a software product's release history across three years. Each section represents a year, and events inside show individual releases. Sections don't have to be time-based. You can use phases, themes, or any logical grouping. ## Events Without Sections You can skip sections entirely for simple timelines: ```mermaid timeline title Key Dates for Product Launch Idea validated : Week 1 MVP built : Week 3 Beta testers recruited : Week 5 Public launch : Week 8 First 100 users : Week 10 ``` **What this does:** Shows a linear sequence of 5 milestones without any grouping. Best for short timelines where you don't need categories. This is the simplest form — just a title and events. Good for roadmaps where phases aren't needed. ## Multi-Event Entries One of the most useful features: multiple events can share the same time period. This is great for showing parallel tasks. ```mermaid timeline title Q1 2026 Sprint Plan section January Backend API design Database schema finalized Team onboarding : Jan 2026 section February Frontend development API integration Unit testing : Feb 2026 section March QA testing Performance optimization Staging deployment : Mar 2026 ``` **What this does:** Shows parallel workstreams in each month. Multiple items are listed under the same section, making it clear that these tasks happen simultaneously. Notice that only the last item in each section gets the `: date` — the others are just labels. This is valid syntax and renders cleanly. ## Styling Your Timeline You can add themes and customize via Mermaid's `%%{init: ...}%%` directive: ```mermaid %%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%% timeline title Team Milestones — Forest Theme section Founding Company incorporated : 2020 First hire : 2020 section Growth Series A raised : 2022 50 employees : 2023 section Scale International expansion : 2025 IPO filed : 2026 ``` **What this does:** Applies the "forest" color theme to the timeline. Available themes: `default`, `forest`, `dark`, `neutral`, `base`. The `logLevel: debug` helps during development when you need to troubleshoot rendering issues. ## Common Mistakes (and How to Fix Them) **Mistake 1: Forgetting the `timeline` keyword** Every diagram needs the type declaration first. `timeline` must be the first non-comment line. **Mistake 2: Missing colons** Event syntax requires `: period`. Without the colon, Mermaid treats the line as a continuation, not a new event. **Mistake 3: Inconsistent indentation** Mermaid uses indentation to understand structure. Keep sections and events consistently indented (2 or 4 spaces — pick one). **Mistake 4: Overly long event labels** Long labels overflow on narrow screens. Keep event text under 40 characters for clean rendering. ## Full Example: Product Launch Timeline Here's a complete, real-world example combining all the concepts: ```mermaid timeline title SaaS Product Launch — 2026 Roadmap section Discovery (Jan) Customer interviews done Problem validated Competitors analyzed : January section Build (Feb-Mar) MVP development Internal alpha testing Bug fixes complete : Feb-Mar section Launch (Apr) Beta program opens Press release published Product Hunt launch : April section Growth (May+) Paid ads start Content marketing live First 500 customers : May onwards ``` **What this does:** A complete SaaS product launch plan, from discovery to growth, mapped across 4 months. This is production-ready — you could put this in a project README today. ## Tips for Better Timelines **Keep it scannable.** Timelines work best when you can read them in 30 seconds. If you're adding more than 6-8 events per section, consider splitting into multiple diagrams. **Use consistent date formats.** Mixing "Jan 2026", "2026-01-01", and "Q1 2026" in the same timeline looks messy. Pick one format and stick to it. **Pair with a Gantt when needed.** If you need to show duration or dependencies between tasks, a [Mermaid Gantt chart](/templates) is a better fit. Timelines show *when*, Gantts show *how long*. **Embed in docs.** Mermaid works natively in GitHub Markdown, Notion, GitLab, and most modern wikis. Write your timeline in plain text and it renders automatically. ## Want to See More Timeline Examples? Check out our post on [10 Mermaid Timeline Examples with Step-by-Step Code](/blog/mermaid-timeline-diagram) for real use cases including research plans, sprint schedules, and historical timelines. For the full syntax reference, visit the [Mermaid Timeline Syntax guide](/blog/mermaid-timeline-diagram). --- **Try this live in our free Mermaid Editor → [mermaideditor.lol](https://mermaideditor.lol)** Paste any of the code blocks above and see your timeline render instantly. No sign-up, no install. Just paste and go. --- *Related: [Mermaid Cheat Sheet](/cheat-sheet) · [Diagram Templates](/templates) · [Home](/)* ## Additional Guide: 10 Mermaid Timeline Examples with Step-by-Step Code (2026) The best way to learn Mermaid timelines is to see real ones — not toy examples, but actual diagrams you'd use in a project. Here are 10 working examples, each with the code and a breakdown of what's happening. Copy any of these, paste into [mermaideditor.lol](https://mermaideditor.lol), and you'll see it render immediately. ## Example 1: Software Sprint Timeline Great for engineering teams doing 2-week sprints. Shows what gets done each sprint without the overhead of a full Gantt chart. ```mermaid timeline title Backend API Project — Sprint Timeline section Sprint 1 (May 1-14) Auth service design DB schema review Auth endpoints live : May 14 section Sprint 2 (May 15-28) User profile API File upload service Integration tests pass : May 28 section Sprint 3 (Jun 1-14) Admin dashboard API Rate limiting Performance benchmarks : Jun 14 section Sprint 4 (Jun 15-30) Security audit Load testing v1.0 shipped : Jun 30 ``` **Step-by-step breakdown:** Four sprints, each 2 weeks. Each section has 2-3 parallel tasks and one milestone (the deliverable). The last event in each section gets the date label — this becomes the anchor point readers scan for. --- ## Example 2: Product Roadmap A high-level roadmap you'd show to stakeholders or put in a pitch deck. ```mermaid timeline title MobileApp Roadmap 2026 section Q1 2026 MVP features defined iOS prototype built Android prototype built : Q1 section Q2 2026 Beta launch (iOS) Beta launch (Android) 1,000 beta users : Q2 section Q3 2026 Public launch App Store featured 10,000 downloads : Q3 section Q4 2026 Premium tier launch Enterprise plan Profitability : Q4 ``` **Step-by-step breakdown:** Quarterly sections, each with 3 events. The last event is always a measurable goal (users, downloads, revenue). This gives stakeholders a story arc, not just a list of tasks. --- ## Example 3: Research Project Plan Academic researchers love this format. See more in our dedicated post on [building a research plan with Mermaid timeline](/blog/mermaid-timeline-diagram). ```mermaid timeline title PhD Research Plan — 3 Year Study section Year 1 Literature review complete Research questions defined Ethics approval received : 2024 section Year 2 Data collection phase 1 Qualitative interviews (n=30) Preliminary analysis done : 2025 section Year 3 Full data analysis Paper submitted to journal Thesis defense : 2026 ``` **Step-by-step breakdown:** Three yearly sections map the arc of a 3-year PhD program. Each section has the key deliverables that supervisors and committees care about. Clean enough to put in a research proposal. --- ## Example 4: Company History Perfect for About pages, investor decks, and onboarding docs. ```mermaid timeline title Acme Corp — Company History section 2018 Founded in garage First product shipped : 2018 section 2019 Seed round ($500K) First 10 employees : 2019 section 2021 Series A ($5M) Opened London office : 2021 section 2023 Series B ($20M) 100 employees milestone : 2023 section 2026 IPO filed Global expansion : 2026 ``` **Step-by-step breakdown:** A company's milestones from founding to IPO. Two events per section keeps it readable. Funding rounds and headcount milestones are the kinds of facts that make company histories scannable. --- ## Example 5: Content Marketing Calendar Editorial teams use this to visualize what's publishing when across channels. ```mermaid timeline title Content Calendar — May 2026 section Week 1 (May 1-7) Blog: SEO fundamentals Newsletter: subscriber growth tips Launch: video series ep.1 : May 7 section Week 2 (May 8-14) Blog: case study Podcast: guest interview Webinar: live Q&A : May 14 section Week 3 (May 15-21) Blog: product update Social: UGC campaign Email: re-engagement : May 21 section Week 4 (May 22-31) Blog: monthly roundup Newsletter: May wrap-up Retrospective: metrics review : May 31 ``` **Step-by-step breakdown:** Weekly sections, each with content across three channels (blog, email, video/social). The last item is either a publish event or a review. Easy to update as the month progresses. --- ## Example 6: Onboarding Journey Map the steps a new user goes through, from sign-up to power user. ```mermaid timeline title New User Onboarding Flow section Day 0 Account created Welcome email sent Profile setup prompt : Day 0 section Day 1 First feature tour Sample project created Invite team prompt : Day 1 section Day 3 Usage tip email Template suggestions Support check-in : Day 3 section Day 7 Power user guide sent Upgrade prompt shown NPS survey triggered : Day 7 section Day 30 Monthly summary email Loyalty reward offered Retention check : Day 30 ``` **Step-by-step breakdown:** Day-based sections show exactly when each touchpoint fires. Product managers use this to spot gaps in onboarding flows. The time labels (Day 0, Day 1, etc.) make the cadence obvious. --- ## Example 7: Event Planning For conferences, launches, or marketing events with multiple workstreams. ```mermaid timeline title Annual Dev Conference — Planning section 6 Months Out Venue booked Speakers recruited Sponsorship packages sent : Nov 2025 section 3 Months Out Agenda published Tickets on sale Marketing campaign live : Feb 2026 section 1 Month Out Catering confirmed AV setup planned Attendee emails sent : Apr 2026 section Event Week Registration opens Keynote rehearsal Conference day 1 : May 2026 ``` **Step-by-step breakdown:** Lead-time sections (6 months, 3 months, 1 month, event week) make this reusable for any event. The approach — counting down instead of counting up — is how event planners actually think. --- ## Example 8: Personal Career Timeline Great for portfolios, LinkedIn "About" sections, or just tracking your own growth. ```mermaid timeline title Career Journey section Early Career Junior Dev at Startup : 2015 First team lead role : 2017 section Mid Career Senior Engineer : 2019 First conference talk : 2020 Open source project (2K stars) : 2021 section Now Principal Engineer : 2023 Started consulting practice : 2025 Author of dev book : 2026 ``` **Step-by-step breakdown:** Three loose phases (early, mid, now) instead of strict years. This gives a narrative arc rather than a flat list of jobs. The standout achievements (conference talk, GitHub stars, book) tell the story better than job titles alone. --- ## Example 9: Security Incident Timeline When a security incident happens, you need a clear timeline for the post-mortem report. ```mermaid timeline title Security Incident — May 5, 2026 section Detection Anomalous login detected Alert triggered in SIEM On-call engineer notified : 02:14 AM section Containment Affected accounts locked API keys rotated External access blocked : 02:45 AM section Investigation Log analysis started Attack vector identified Scope confirmed (3 accounts) : 04:30 AM section Recovery Accounts restored Security patches applied All-clear declared : 09:00 AM ``` **Step-by-step breakdown:** Time-stamped sections (02:14, 02:45, etc.) make incident timelines precise. Four phases — Detection, Containment, Investigation, Recovery — follow the standard incident response framework. This format goes directly into a post-mortem doc. --- ## Example 10: Learning Path / Curriculum For courses, bootcamps, or self-study plans. ```mermaid timeline title Full-Stack Developer Learning Path section Foundations (Month 1) HTML & CSS basics JavaScript fundamentals First static website : Month 1 section Frontend (Month 2-3) React basics State management Built 3 portfolio projects : Month 3 section Backend (Month 4-5) Node.js & Express SQL & databases REST API built : Month 5 section Full Stack (Month 6) Deploy to cloud Auth & security Capstone project shipped : Month 6 ``` **Step-by-step breakdown:** A 6-month bootcamp curriculum in one diagram. Each section ends with a concrete deliverable (website, projects, API, capstone). Instructors can use this as the first slide of an orientation session. --- ## Which Example Should You Start With? - **Engineering teams:** Examples 1 (sprint) or 9 (incident) are immediately practical. - **Product managers:** Examples 2 (roadmap) or 7 (event) give you stakeholder-ready visuals fast. - **Researchers/academics:** Examples 3 (research plan) and 10 (learning path) map directly to your work. - **Content teams:** Example 5 (content calendar) will replace your spreadsheet. Want to dive deeper into the syntax? Read the [complete Mermaid timeline instructions guide](/blog/mermaid-timeline-diagram) or the [timeline syntax reference](/blog/mermaid-timeline-diagram). --- **Try these live in our free Mermaid Editor → [mermaideditor.lol](https://mermaideditor.lol)** Paste any example above and watch it render in real-time. No setup, no account needed. --- *Related: [Mermaid Cheat Sheet](/cheat-sheet) · [Diagram Templates](/templates) · [Home](/)* ## Additional Guide: Mermaid Timeline Syntax: Every Element Explained with Examples This is the definitive syntax reference for Mermaid timelines. Not a beginner's intro — a complete element-by-element breakdown of every syntax feature, with working examples and the edge cases you'll actually hit. If you're new to timelines, start with the [Mermaid Timeline Instructions Guide](/blog/mermaid-timeline-diagram). Come back here when you need the specific syntax for something. ## Diagram Declaration Every Mermaid timeline starts with the `timeline` keyword on its own line: ```mermaid timeline title My First Timeline Event 1 : Period 1 Event 2 : Period 2 ``` **What this does:** The simplest valid timeline — a title and two events. `timeline` is the type declaration. Without it, Mermaid doesn't know which diagram type you're writing. **Edge case:** `Timeline` (capital T) does NOT work. The keyword is case-sensitive: `timeline` only. --- ## Title Element ```mermaid timeline title Product Roadmap 2026 Launch MVP : Q1 Beta program : Q2 Public launch : Q3 ``` **Syntax:** `title Your Title Text` **Rules:** - Goes immediately after the `timeline` declaration - Optional — timelines render without a title - One title only — multiple `title` lines cause parse errors - No quotes needed, even with spaces **What this does:** Adds a heading above the timeline. Recommended for any timeline that will be shared or embedded in docs — gives immediate context. --- ## Event Syntax The core building block: ```mermaid timeline title Event Syntax Examples Single event : Period A Another event : Period B Third event : Period C ``` **Syntax:** `EventLabel : TimePeriod` The colon `:` separates the event label from the time period. Both sides are plain text — no quoting needed unless you need special characters. **What this does:** Three events mapped to three periods. The period (right of the colon) is what renders as the time label in the diagram. **Edge cases:** - Missing colon: the line is treated as a multi-event entry (see below), not a new event with a period - Extra spaces around the colon are fine: `Event : Period` and `Event:Period` both work - Long event labels: keep under 50 chars for clean rendering. Longer labels wrap or overflow. --- ## Section Element Sections group events into visual blocks: ```mermaid timeline title Grouped by Phase section Phase 1 Research complete Prototype built : Month 1 section Phase 2 User testing done Feedback analyzed : Month 2 section Phase 3 Final version shipped Documentation done : Month 3 ``` **Syntax:** `section Section Name` **Rules:** - Sections must come before their events (events are indented under the section) - A timeline can mix sections and non-section events — though it's cleaner to use one or the other - Section names appear as visual dividers in the rendered diagram - No `end` keyword needed — the next `section` or end of file closes the current one **What this does:** Adds visual grouping. Three phases, each with two events. The section header acts like a category label for the events underneath. --- ## Multi-Event Entries (Parallel Events) Multiple events can share the same time period: ```mermaid timeline title Parallel Work in Q1 section January Backend API built Frontend prototype Mobile wireframes : January section February API integration Frontend polish Mobile beta build : February ``` **Syntax:** List multiple items under a section. Only the last item gets the `: Period` marker. The others are treated as additional events for the same period. **What this does:** Shows three parallel work streams in each month. January has three simultaneous activities; February has three more. The time period only appears once (on the last item), preventing visual clutter. **Edge case:** All items above the colon-marked one render as events for the same period. If you accidentally omit the colon from every item in a section, Mermaid may render them oddly — always have exactly one `event : period` per section as the anchor. --- ## Date and Period Formats Mermaid timelines are format-agnostic. The period text is just a label — Mermaid doesn't validate or parse dates: ```mermaid timeline title Date Format Flexibility Project kick-off : 2026-01-01 Sprint 1 ends : January 14 Beta launch : Q1 2026 Public launch : Spring 2026 Year-end review : Dec 2026 ``` **What this does:** Shows five different date/period formats in one diagram. ISO dates, natural language months, quarter notation, seasons, and abbreviated months — all valid. Pick the format that matches your audience's expectations. **Best practice:** Be consistent within a single timeline. Mixing formats (ISO dates in section 1, "Q1/Q2" in section 2) looks unprofessional. Choose one convention and stick to it. --- ## Theme Configuration Apply Mermaid's built-in themes via the `%%{init}%%` directive: ```mermaid %%{init: { 'theme': 'forest' } }%% timeline title Forest Theme Timeline section 2024 Planted seeds First growth : 2024 section 2025 Rapid expansion Maturity reached : 2025 section 2026 Full bloom : 2026 ``` **Syntax:** `%%{init: { 'theme': 'THEMENAME' } }%%` on the line before `timeline` **Available themes:** `default`, `forest`, `dark`, `neutral`, `base` **What this does:** Applies the "forest" color theme to the entire diagram. The `%%{init}%%` directive tells the Mermaid renderer to apply these settings before rendering. **Note:** The init directive affects the whole diagram. You can also set `logLevel`, `fontFamily`, and other renderer options in the same object. --- ## Custom Styling via init More advanced customization through the init block: ```mermaid %%{init: { 'theme': 'base', 'themeVariables': { 'primaryColor': '#7B2D8B', 'primaryTextColor': '#fff', 'lineColor': '#7B2D8B' } } }%% timeline title Custom Color Timeline Feature A shipped : Q1 Feature B launched : Q2 Feature C in beta : Q3 Full suite complete : Q4 ``` **What this does:** Sets custom colors using `themeVariables`. `primaryColor` changes the section/event block color. `primaryTextColor` sets text color inside blocks. `lineColor` sets the connecting line color. Use hex codes. --- ## Section-Free Timelines For simple linear sequences, skip sections entirely: ```mermaid timeline title Simple Linear Timeline Idea formed : Week 1 Research done : Week 2 Prototype built : Week 4 Tested with users : Week 6 Shipped : Week 8 ``` **What this does:** A clean 5-event linear timeline with no section grouping. Works best for short timelines (under 8 events) where the events are sequential and don't need categorization. --- ## Long Labels and Wrapping ```mermaid timeline title Labels of Different Lengths Short : Jan A medium-length event label here : Feb This is a much longer event label that will test wrapping behavior : Mar Back to short : Apr ``` **What this does:** Tests how labels of different lengths render. Short labels are clean. Medium labels work fine. Very long labels will wrap or overflow depending on the renderer. **Rule of thumb:** Keep event labels under 50 characters. If you need more context, put it in a supporting document and keep the timeline label concise. --- ## Nesting Sections: What Works and What Doesn't Mermaid timelines do NOT support nested sections. You can't do: ``` section Phase 1 section Sub-phase 1a ``` This will either parse incorrectly or render as a section named "section Sub-phase 1a". If you need hierarchy, use a different diagram type: - For hierarchical breakdowns: use a **mindmap** - For task dependencies: use a **Gantt chart** - For process hierarchy: use a **flowchart** --- ## Complete Syntax Quick Reference | Element | Syntax | Example | |---------|--------|---------| | Diagram start | `timeline` | `timeline` | | Title | `title Text` | `title My Timeline` | | Section | `section Name` | `section Q1 2026` | | Event with period | `Label : Period` | `Launch : June 2026` | | Event without period | `Label` | `Feature built` | | Theme | `%%{init: {'theme': 'x'}}%%` | before `timeline` line | | Comment | `%% comment text` | `%% TODO: add events` | --- ## Common Parse Errors and Fixes **Error: "Diagram not rendered"** Usually means a typo in the `timeline` keyword, or the init directive is malformed. **Error: Events in wrong section** Check your indentation. Section events must be indented relative to the section keyword. **Diagram renders but missing events** A missing colon means the line was parsed as a multi-event item without a period anchor. Add `: period` to the event. **All events show same period** Every event in a section without its own colon inherits the last anchored period. Make sure each period group has exactly one `: period` marker. --- ## Related Timeline Resources - [Mermaid Timeline Instructions: Full Guide](/blog/mermaid-timeline-diagram) — beginner-friendly walkthrough - [10 Timeline Examples with Step-by-Step Code](/blog/mermaid-timeline-diagram) — real use cases - [Research Plan Timeline Examples](/blog/mermaid-timeline-diagram) — academic and UX research --- **Try this live in our free Mermaid Editor → [mermaideditor.lol](https://mermaideditor.lol)** Every syntax example on this page works in our editor. Test edge cases, experiment with themes, and export your finished timeline. --- *Related: [Mermaid Cheat Sheet](/cheat-sheet) · [Diagram Templates](/templates) · [Home](/)* ## Additional Guide: Building a Research Plan with Mermaid Timeline: Real Examples A research plan without a timeline is just a list of intentions. Adding a Mermaid timeline turns it into a visual schedule that supervisors, collaborators, and stakeholders can scan in 10 seconds. This post shows how to build research timelines for different contexts: academic studies, UX research, market research, and literature reviews. All examples are ready to copy and use. ## Why Use Mermaid for Research Timelines? Most researchers use Excel Gantt charts or PowerPoint slides for timelines. Both work, but both require manual updates when plans shift. Mermaid timelines live in plain text — change a date, re-render, done. **Practical advantages:** - Embed directly in GitHub READMEs, Notion docs, or Confluence pages - Version-control your timeline alongside your code or notes - Share as markdown — no software required to view - Update in seconds vs. reformatting cells/slides For the underlying syntax, read the [complete Mermaid timeline instructions guide](/blog/mermaid-timeline-diagram). ## Example 1: Academic Research Plan (1-Year Study) ```mermaid timeline title Year 1 Academic Research Plan section Q1 (Jan-Mar) Background reading Gap analysis complete Research questions finalized : March section Q2 (Apr-Jun) Ethics board submission Ethics approval received Pilot study designed : June section Q3 (Jul-Sep) Pilot data collected (n=10) Pilot analysis done Main study protocol set : September section Q4 (Oct-Dec) Main data collection begins Interim analysis Year 1 report submitted : December ``` **What this does:** Maps a full year of academic research across four quarters. The Q structure aligns with how most universities report progress. Ethics approval is correctly placed in Q2 (before any data collection). The deliverable at the end of each quarter is what gets reviewed in supervision meetings. **How to adapt it:** Change the section labels to match your actual timeline. If your ethics board is slow, push Q2 back and compress Q3. The beauty of plain text is you can do this in 30 seconds. --- ## Example 2: UX Research Plan UX research moves faster than academic research. This plan covers a 6-week discovery sprint. ```mermaid timeline title UX Research — Discovery Sprint (6 Weeks) section Week 1-2 Stakeholder interviews (5 sessions) Research brief approved Screener survey live : Week 2 section Week 3-4 User interviews (10 participants) Contextual observation sessions Affinity mapping workshop : Week 4 section Week 5 Theme synthesis Journey map draft Insight statements written : Week 5 section Week 6 Final presentation prepared Readout to product team Research report delivered : Week 6 ``` **What this does:** Shows a 6-week UX research sprint from stakeholder interviews through final delivery. The progression — interviews → synthesis → insights → presentation — follows the standard double-diamond research process. Product managers and designers immediately recognize this structure. **Key detail:** Parallel activities within weeks are shown as multiple events in the same section. "User interviews (10 participants)" and "Contextual observation sessions" both happen in weeks 3-4, which this diagram makes clear. --- ## Example 3: Literature Review Timeline For PhD students and academic researchers, the literature review often takes longer than expected. This timeline forces clarity. ```mermaid timeline title Systematic Literature Review — 12 Weeks section Search Phase (Wk 1-3) Search terms defined Databases selected (5) Initial search run — 847 papers : Week 3 section Screening Phase (Wk 4-6) Title & abstract screening Full-text eligibility check Included papers confirmed — 62 : Week 6 section Extraction Phase (Wk 7-9) Data extraction template built Quality assessment complete All 62 papers extracted : Week 9 section Synthesis Phase (Wk 10-12) Thematic analysis Findings narrative written Literature review submitted : Week 12 ``` **What this does:** A PRISMA-style systematic literature review mapped to 12 weeks. The numbers (847 papers → 62 included) are placeholders you'd replace with your actual PRISMA flow numbers. Supervisors love seeing this level of process rigor in a single diagram. --- ## Example 4: Market Research Plan Businesses doing market research before a product launch typically need to cover primary and secondary research. Here's a 10-week plan: ```mermaid timeline title Market Research Plan — Product Launch Prep section Secondary Research (Wk 1-2) Industry report analysis Competitor matrix built TAM/SAM/SOM calculated : Week 2 section Survey Design (Wk 3-4) Survey questions written Panel vendor selected Survey live (n=500 target) : Week 4 section Primary Research (Wk 5-7) Survey data collected Focus groups (3 sessions) Interview transcripts coded : Week 7 section Analysis (Wk 8-9) Quantitative analysis done Qualitative themes identified Key personas drafted : Week 9 section Deliverables (Wk 10) Executive summary written Presentation slides built Board readout complete : Week 10 ``` **What this does:** Separates secondary research (desk research, reports) from primary research (surveys, focus groups), which is how market research actually gets structured. The board readout at week 10 is the real deliverable this whole plan is working toward. --- ## Example 5: Mixed-Methods Research Design For studies combining quantitative and qualitative data collection: ```mermaid timeline title Mixed-Methods Study — 18 Month Timeline section Phase 1: Quantitative (Month 1-6) Survey instrument validated Random sample recruited (n=200) Survey data collected Statistical analysis complete : Month 6 section Phase 2: Qualitative (Month 7-12) Interview guide developed Purposive sample recruited (n=25) Semi-structured interviews run Thematic analysis complete : Month 12 section Phase 3: Integration (Month 13-18) QUAN + QUAL findings merged Joint display created Meta-inferences written Thesis chapter submitted : Month 18 ``` **What this does:** Shows the sequential QUAN → QUAL → integration structure of a convergent mixed-methods design. The final "integration" phase — where quantitative and qualitative findings are merged — is where mixed-methods studies often get vague. Putting it explicitly in the timeline forces the researcher to plan for it. --- ## Tips for Research Timeline Diagrams **Be specific about deliverables.** "Analysis done" is vague. "All 62 papers extracted" tells you exactly what completion looks like. Concrete deliverables make it easier to know if you're on schedule. **Account for buffer.** Real research always hits delays: ethics board slowdowns, participant no-shows, data quality issues. Build a week of buffer into every major phase. **Version your timeline.** When plans change (and they will), keep the old version in a separate file. Supervisors appreciate seeing how your plan evolved — it shows adaptive thinking. **Link to your protocol.** If your timeline lives in a README or Notion page, link it to your actual research protocol document. The timeline is the overview; the protocol has the detail. --- ## See More Timeline Examples For more timeline patterns — sprints, content calendars, onboarding flows — see [10 Mermaid Timeline Examples with Step-by-Step Code](/blog/mermaid-timeline-diagram). For the full syntax reference, read [Mermaid Timeline Syntax: Every Element Explained](/blog/mermaid-timeline-diagram). --- **Try this live in our free Mermaid Editor → [mermaideditor.lol](https://mermaideditor.lol)** Paste any of the research timeline examples above and customize them for your project. Takes 5 minutes to go from blank page to presentation-ready diagram. --- *Related: [Mermaid Cheat Sheet](/cheat-sheet) · [Diagram Templates](/templates) · [Home](/)* ### What is Mermaid.js? A Beginner's Introduction to Diagrams as Code URL: https://mermaideditor.lol/blog/what-is-mermaid-js Published: 2025-12-01 Updated: 2025-12-01 Description: Learn what Mermaid.js is, how it works, and why developers love creating diagrams from simple text. A complete beginner's guide to diagrams as code. ## What is Mermaid.js? Mermaid.js is a JavaScript-based diagramming and charting tool that turns simple text definitions into rich, visual diagrams. Instead of dragging boxes and arrows around in a GUI, you write a few lines of human-readable text, and Mermaid renders the diagram for you. Think of it as **Markdown, but for diagrams**. Just as Markdown lets you write formatted documents without a word processor, Mermaid lets you create flowcharts, sequence diagrams, Gantt charts, and more without a drawing tool. ### A Quick Example Here's how simple it is. This text: ``` graph TD A[Write Code] --> B[Commit] B --> C[Push to GitHub] C --> D[Deploy] ``` Produces a clean flowchart showing a basic deployment pipeline. No mouse dragging, no alignment headaches — just text. ## Why Developers Love Mermaid.js ### 1. Version Control Friendly Because diagrams are plain text, they live in your Git repository alongside your code. You can track changes, review diffs, and merge updates just like any other source file. Try doing that with a PNG exported from a drawing tool. ### 2. Speed of Creation Creating a diagram in Mermaid takes seconds, not minutes. Once you learn the syntax, you can sketch out architectures, flows, and relationships faster than you could open a GUI tool. The mental model stays in text, which is where developers already live. ### 3. Always Up to Date When diagrams live next to the code they describe, they're far more likely to stay current. A diagram in a README file gets updated in the same pull request that changes the architecture. Traditional diagrams in separate files or external tools tend to go stale quickly. ### 4. Platform Support Mermaid diagrams render natively in **GitHub**, **GitLab**, **Notion**, **Obsidian**, **Confluence** (via plugins), and many other platforms. You don't need a special viewer — the platforms render them inline. ### 5. No Account Required Unlike SaaS diagramming tools, Mermaid is open-source and runs in the browser. There's no sign-up, no subscription, no vendor lock-in. Your diagrams are portable text files. ## What Types of Diagrams Can You Create? Mermaid supports a wide variety of diagram types, each suited for different use cases: | Diagram Type | Best For | |---|---| | **Flowchart** | Process flows, decision trees, algorithms | | **Sequence Diagram** | API calls, service interactions, protocols | | **Gantt Chart** | Project timelines, sprint planning | | **Class Diagram** | UML modeling, object-oriented design | | **State Diagram** | State machines, workflow states | | **Entity Relationship** | Database schema, data modeling | | **Pie Chart** | Simple data distribution | | **Mind Map** | Brainstorming, topic organization | | **Git Graph** | Branch visualization | | **Timeline** | Historical events, roadmaps | Each diagram type has its own simple syntax, but they all follow the same pattern: a declaration line followed by relationships. ## Getting Started with Mermaid.js ### Option 1: Use a Live Editor The fastest way to try Mermaid is with an online editor. You type on the left, see the diagram on the right. No installation needed. ### Option 2: Add to Your Website Include Mermaid in any HTML page: ```html
graph LR
A --> B --> C
```
### Option 3: Use in Markdown
On platforms like GitHub, simply wrap your diagram in a mermaid code fence:
```
```mermaid
graph TD
A --> B
```
```
GitHub will render it automatically — no plugins needed.
### Option 4: Install via npm
For programmatic use in Node.js or build tools:
```bash
npm install mermaid
```
## Your First Flowchart
Let's build a practical example — a user login flow:
```
graph TD
Start([User visits site]) --> Check{Logged in?}
Check -- Yes --> Dashboard[Show Dashboard]
Check -- No --> Login[Show Login Form]
Login --> Submit[User submits credentials]
Submit --> Validate{Valid?}
Validate -- Yes --> Dashboard
Validate -- No --> Error[Show Error]
Error --> Login
```
This creates a complete login flow diagram with decision points, loops, and clear labels. Notice how readable the source text is — even without rendering, you can understand the flow.
## Key Syntax Concepts
**Nodes** are defined with text in brackets:
- `A[Rectangle]` — standard box
- `A(Rounded)` — rounded corners
- `A{Diamond}` — decision/rhombus
- `A([Stadium])` — stadium shape
- `A([Circle])` — circle
**Edges** connect nodes:
- `A --> B` — arrow
- `A --- B` — line without arrow
- `A -->|label| B` — arrow with label
- `A -.-> B` — dotted arrow
- `A ==> B` — thick arrow
**Direction** is set on the first line:
- `graph TD` — top to bottom
- `graph LR` — left to right
- `graph BT` — bottom to top
- `graph RL` — right to left
## Mermaid.js vs Traditional Tools
How does Mermaid compare to tools like Draw.io, Lucidchart, or Visio?
**Mermaid wins at:** speed, version control, documentation integration, automation, and cost (free).
**Traditional tools win at:** pixel-perfect layouts, complex custom styling, non-technical users, and presentation-ready output.
The sweet spot for Mermaid is **technical documentation** — README files, architecture docs, design documents, and wikis. For marketing materials or highly styled presentations, a GUI tool may be better.
## Common Use Cases
1. **Architecture diagrams** in project READMEs
2. **API flow documentation** with sequence diagrams
3. **Database schemas** with ER diagrams
4. **Sprint planning** with Gantt charts
5. **Decision trees** for business logic
6. **Onboarding docs** showing system overview
7. **State machines** for UI components or workflows
## Tips for Beginners
- **Start simple.** Get a basic flowchart working, then explore other diagram types.
- **Use a live editor** to see results instantly as you type.
- **Read the official docs** at [mermaid.js.org](https://mermaid.js.org) for syntax details.
- **Copy examples** and modify them — it's the fastest way to learn.
- **Keep diagrams focused.** One diagram per concept. If it's getting complex, split it.
## Conclusion
Mermaid.js bridges the gap between text-based documentation and visual communication. It's fast, free, version-controllable, and increasingly supported across the platforms developers already use. Whether you're documenting an API, planning a project, or modeling a database, Mermaid lets you create professional diagrams without leaving your text editor.
[Try it now in our free Mermaid Live Editor →](/)
### How to Create a Flowchart with Mermaid.js — Complete Guide
URL: https://mermaideditor.lol/blog/how-to-create-flowchart-mermaid
Published: 2025-12-05
Updated: 2025-12-05
Description: Step-by-step guide to creating flowcharts with Mermaid.js. Learn node shapes, edge types, styling, subgraphs, and best practices with copy-paste examples.
## Introduction to Mermaid Flowcharts
Flowcharts are the most popular diagram type in Mermaid.js, and for good reason. They're versatile enough to represent everything from simple processes to complex decision trees, and Mermaid makes them incredibly easy to create with just a few lines of text.
In this guide, you'll learn every aspect of Mermaid flowcharts — from basic syntax to advanced features like subgraphs, styling, and interaction.
## Basic Flowchart Syntax
Every Mermaid flowchart starts with a direction declaration:
```
graph TD
A[Start] --> B[Process]
B --> C[End]
```
The direction keyword controls layout:
- **TD** or **TB** — Top to Bottom (default, most common)
- **LR** — Left to Right (great for pipelines)
- **BT** — Bottom to Top
- **RL** — Right to Left
You can also use `flowchart` instead of `graph` for the newer syntax with more features:
```
flowchart LR
A[Start] --> B[Process] --> C[End]
```
## Node Shapes
Mermaid provides many node shapes to convey meaning visually:
```
flowchart TD
A[Rectangle - Default]
B(Rounded Rectangle)
C([Stadium Shape])
D[[Subroutine]]
E[(Database / Cylinder)]
F((Circle))
G{Diamond / Decision}
H{{"Hexagon"}}
I>Asymmetric / Flag]
J[/Parallelogram/]
K[\Parallelogram Alt\]
L[/Trapezoid\]
M[\Trapezoid Alt/]
```
### When to Use Each Shape
- **Rectangle** (`[text]`): Standard process steps
- **Rounded** (`(text)`): Start/end terminals
- **Diamond** (`{text}`): Decision points (yes/no, true/false)
- **Cylinder** (`[(text)]`): Databases or storage
- **Circle** (`((text))`): Connectors or junction points
- **Stadium** (`([text])`): Terminal events
- **Parallelogram** (`[/text/]`): Input/output operations
## Edge Types — Connecting Nodes
Edges (arrows and lines) are how you connect nodes. Mermaid offers many styles:
```
flowchart LR
A -->|Arrow| B
C ---|Line| D
E -.->|Dotted arrow| F
G ==>|Thick arrow| H
I --o|Circle end| J
K --x|Cross end| L
```
### Edge Length
You can control edge length by adding extra dashes:
```
flowchart TD
A --> B
A ----> C
A -------> D
```
Longer edges push nodes further apart, which helps with layout.
### Labeled Edges
Add labels to describe the relationship:
```
flowchart TD
A{Is it raining?}
A -->|Yes| B[Take umbrella]
A -->|No| C[Enjoy the sun]
```
You can also use this syntax: `A -- "label text" --> B`
## Practical Example: CI/CD Pipeline
Let's build a real-world flowchart — a CI/CD deployment pipeline:
```
flowchart LR
A([Developer pushes code]) --> B[Run Linter]
B --> C[Run Unit Tests]
C --> D{Tests pass?}
D -->|Yes| E[Build Docker Image]
D -->|No| F[Notify Developer]
F --> A
E --> G[Push to Registry]
G --> H{Environment?}
H -->|Staging| I[Deploy to Staging]
H -->|Production| J[Manual Approval]
J --> K[Deploy to Production]
I --> L[Run E2E Tests]
L --> M{E2E pass?}
M -->|Yes| J
M -->|No| F
```
This single text block produces a complete CI/CD visualization that's easy to update when the process changes.
## Subgraphs — Grouping Related Nodes
Subgraphs let you group nodes into labeled sections:
```
flowchart TB
subgraph Frontend
A[React App] --> B[API Client]
end
subgraph Backend
C[Express Server] --> D[Business Logic]
D --> E[(PostgreSQL)]
end
B --> C
```
### Nested Subgraphs
You can nest subgraphs for complex architectures:
```
flowchart TB
subgraph Cloud["AWS Cloud"]
subgraph VPC["VPC"]
subgraph Public["Public Subnet"]
ALB[Load Balancer]
end
subgraph Private["Private Subnet"]
ECS[ECS Service]
RDS[(RDS Database)]
end
end
end
User([User]) --> ALB --> ECS --> RDS
```
### Subgraph Direction
Each subgraph can have its own direction:
```
flowchart LR
subgraph TOP
direction TB
A --> B
end
subgraph BOTTOM
direction TB
C --> D
end
TOP --> BOTTOM
```
## Styling Your Flowcharts
### Inline Styles
Apply CSS-like styles directly to nodes:
```
flowchart LR
A[Critical]:::critical --> B[Normal] --> C[Success]:::success
classDef critical fill:#ff6b6b,stroke:#c0392b,color:white
classDef success fill:#51cf66,stroke:#2f9e44,color:white
```
### Style by Node ID
```
flowchart TD
A[Important Node]
style A fill:#f9f,stroke:#333,stroke-width:4px
```
### Common Style Patterns
Here's a reusable set of class definitions:
```
flowchart TD
A[Start]:::start --> B[Process]:::process --> C{Decision}:::decision
C -->|Yes| D[Success]:::success
C -->|No| E[Error]:::error
classDef start fill:#667eea,stroke:#5a67d8,color:white
classDef process fill:#f7fafc,stroke:#cbd5e0
classDef decision fill:#faf089,stroke:#d69e2e
classDef success fill:#c6f6d5,stroke:#38a169
classDef error fill:#fed7d7,stroke:#e53e3e
```
## Advanced Techniques
### Multiple Links from One Node
```
flowchart TD
A[Router] --> B[Handler 1]
A --> C[Handler 2]
A --> D[Handler 3]
B & C & D --> E[Response]
```
The `&` operator connects multiple nodes at once.
### Special Characters in Labels
Use quotes for special characters:
```
flowchart LR
A["Node with (parentheses)"] --> B["Contains {braces}"]
B --> C["Has #quot;quotes#quot;"]
```
### Comments
Add comments with `%%`:
```
flowchart TD
%% This is a comment
A --> B
%% Another comment
B --> C
```
## Best Practices for Flowcharts
1. **Choose direction wisely.** Use LR for processes/pipelines, TD for hierarchies and decision trees.
2. **Use meaningful node IDs.** Instead of `A`, `B`, `C`, try `start`, `validate`, `deploy`. It makes the source readable.
3. **Label your edges.** Decision diamonds should always have labeled outputs (Yes/No, True/False, Success/Error).
4. **Keep it focused.** A flowchart with more than 15-20 nodes becomes hard to read. Split complex flows into multiple diagrams.
5. **Use subgraphs** for logical grouping. They make large diagrams scannable.
6. **Apply consistent styling.** Define class definitions once and reuse them. Color-code by category (errors = red, success = green, etc.).
7. **Test incrementally.** Build your flowchart step by step, rendering after each addition. This makes it easy to catch syntax errors.
## Common Mistakes and Fixes
**Problem:** Nodes not connecting properly.
**Fix:** Make sure node IDs are consistent. `A` and `a` are different nodes.
**Problem:** Text with special characters breaks rendering.
**Fix:** Wrap text in double quotes: `A["My (special) text"]`
**Problem:** Layout is messy with too many crossing lines.
**Fix:** Rearrange node order in the source. Mermaid renders top-to-bottom in the order nodes appear. Also try changing direction (LR vs TD).
**Problem:** Subgraph edges look wrong.
**Fix:** Connect to specific nodes inside subgraphs, not the subgraph itself.
## Conclusion
Mermaid flowcharts are powerful enough for real-world documentation yet simple enough to create in seconds. Start with basic nodes and arrows, then progressively add shapes, styles, and subgraphs as needed. The key advantage is maintainability — when your process changes, updating a few lines of text is infinitely easier than rearranging boxes in a drawing tool.
[Try it now in our free Mermaid Live Editor →](/)
### Mermaid Sequence Diagram Tutorial with Examples
URL: https://mermaideditor.lol/blog/mermaid-sequence-diagram-tutorial
Published: 2025-12-08
Updated: 2025-12-08
Description: Learn how to create sequence diagrams with Mermaid.js. Covers participants, messages, loops, alt blocks, notes, and activation with real-world examples.
## What Are Sequence Diagrams?
Sequence diagrams show how different components or actors interact over time. They're perfect for documenting API calls, microservice communication, authentication flows, and any process where the **order of messages** matters.
Mermaid makes sequence diagrams easy to write and maintain — no drawing tools needed.
## Basic Syntax
```
sequenceDiagram
Alice->>Bob: Hello Bob, how are you?
Bob-->>Alice: Great!
```
The key elements:
- **Participants** are automatically created when first mentioned
- **Solid arrow** (`->>`) = synchronous message
- **Dashed arrow** (`-->>`) = response / async message
- Messages are labeled after the colon
## Arrow Types
Mermaid supports several arrow types for different message semantics:
```
sequenceDiagram
A->>B: Solid line with arrowhead (sync call)
B-->>A: Dotted line with arrowhead (response)
A-)B: Solid line with open arrow (async)
B--)A: Dotted line with open arrow (async response)
A-xB: Solid line with cross (lost message)
B--xA: Dotted line with cross
```
## Defining Participants
You can explicitly declare participants to control order and add aliases:
```
sequenceDiagram
participant U as User
participant F as Frontend
participant A as API Server
participant D as Database
U->>F: Click "Login"
F->>A: POST /auth/login
A->>D: SELECT user WHERE email=?
D-->>A: User record
A-->>F: JWT token
F-->>U: Redirect to dashboard
```
Use `actor` instead of `participant` to show a stick figure:
```
sequenceDiagram
actor User
participant API
User->>API: Request
API-->>User: Response
```
## Activation Bars
Activation bars show when a participant is actively processing:
```
sequenceDiagram
Client->>+Server: HTTP Request
Server->>+Database: Query
Database-->>-Server: Results
Server-->>-Client: HTTP Response
```
The `+` activates (starts the bar) and `-` deactivates (ends it). You can also use explicit syntax:
```
sequenceDiagram
Client->>Server: Request
activate Server
Server->>Database: Query
activate Database
Database-->>Server: Results
deactivate Database
Server-->>Client: Response
deactivate Server
```
## Real-World Example: OAuth 2.0 Flow
```
sequenceDiagram
actor User
participant App as Client App
participant Auth as Auth Server
participant API as Resource Server
User->>App: Click "Login with Google"
App->>Auth: Redirect to /authorize
Auth->>User: Show consent screen
User->>Auth: Grant permission
Auth-->>App: Authorization code
App->>+Auth: Exchange code for token
Auth-->>-App: Access token + Refresh token
App->>+API: GET /user (Bearer token)
API-->>-App: User profile data
App-->>User: Show profile
```
## Loops
Show repeated interactions:
```
sequenceDiagram
participant Client
participant Server
Client->>Server: Connect
loop Every 30 seconds
Client->>Server: Heartbeat ping
Server-->>Client: Pong
end
Client->>Server: Disconnect
```
## Alt / Else Blocks (Conditionals)
Show branching logic:
```
sequenceDiagram
participant User
participant API
participant DB
User->>API: POST /login
API->>DB: Check credentials
alt Valid credentials
DB-->>API: User found
API-->>User: 200 OK + Token
else Invalid credentials
DB-->>API: Not found
API-->>User: 401 Unauthorized
end
```
## Optional Blocks
The `opt` block shows something that may or may not happen:
```
sequenceDiagram
participant User
participant Cart
participant Payment
User->>Cart: Add items
User->>Cart: Checkout
opt Has coupon
User->>Cart: Apply coupon code
Cart-->>User: Discount applied
end
Cart->>Payment: Process payment
Payment-->>Cart: Confirmation
Cart-->>User: Order complete
```
## Parallel (Par) Blocks
Show things happening simultaneously:
```
sequenceDiagram
participant App
participant UserSvc as User Service
participant OrderSvc as Order Service
participant NotifSvc as Notification Service
App->>App: User places order
par Parallel requests
App->>UserSvc: Get user details
App->>OrderSvc: Create order
App->>NotifSvc: Send confirmation
end
UserSvc-->>App: User data
OrderSvc-->>App: Order ID
NotifSvc-->>App: Sent OK
```
## Notes
Add notes for extra context:
```
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: TLS Handshake
C->>S: ClientHello
S-->>C: ServerHello + Certificate
C->>S: Key Exchange
Note over C,S: Encrypted connection established
C->>S: GET /api/data
Note right of S: Validate token, query DB
S-->>C: 200 OK + JSON
```
Note positions: `Note left of`, `Note right of`, `Note over A,B` (spans multiple participants).
## Critical Regions
Highlight critical sections:
```
sequenceDiagram
participant App
participant DB
App->>DB: BEGIN TRANSACTION
critical Database Transaction
App->>DB: UPDATE accounts SET balance = balance - 100 WHERE id = 1
App->>DB: UPDATE accounts SET balance = balance + 100 WHERE id = 2
option Transaction fails
DB-->>App: ROLLBACK
end
App->>DB: COMMIT
DB-->>App: OK
```
## Autonumber
Automatically number each message for easy reference:
```
sequenceDiagram
autonumber
Alice->>Bob: Request
Bob->>Charlie: Forward
Charlie-->>Bob: Response
Bob-->>Alice: Response
```
## Real-World Example: Microservice Order Flow
```
sequenceDiagram
autonumber
actor Customer
participant GW as API Gateway
participant OS as Order Service
participant IS as Inventory Service
participant PS as Payment Service
participant NS as Notification Service
Customer->>+GW: POST /orders
GW->>+OS: Create order
OS->>+IS: Check stock
IS-->>-OS: In stock
OS->>+PS: Charge customer
alt Payment success
PS-->>-OS: Payment confirmed
OS->>NS: Send confirmation email
NS-->>OS: Queued
OS-->>-GW: Order created (201)
GW-->>-Customer: Order confirmation
else Payment failed
PS-->>OS: Payment declined
OS->>IS: Release reservation
OS-->>GW: Payment failed (402)
GW-->>Customer: Error message
end
```
## Best Practices
1. **Declare participants explicitly** to control the order they appear left-to-right.
2. **Use aliases** for long service names — `participant PS as Payment Service`.
3. **Use activation bars** to show processing duration — it makes timing clear.
4. **Add autonumber** when you'll reference steps in documentation ("In step 3, the server validates...").
5. **Use alt/else** for error handling flows — document both happy and sad paths.
6. **Keep it focused** — one sequence diagram per use case. Don't try to show every possible flow in one diagram.
7. **Add notes** for non-obvious details like "Token expires in 1 hour" or "Retries 3 times".
## Common Pitfalls
- **Forgetting the closing `end`** for loop/alt/opt/par blocks — each needs a matching end.
- **Too many participants** — more than 6-7 makes the diagram too wide. Group related services.
- **Missing responses** — every request should ideally have a response shown, even if it's async.
## Conclusion
Sequence diagrams are essential for documenting how systems communicate. Mermaid's text-based approach means your diagrams stay in sync with your code, live in your repo, and are easy to update. Start with the basic arrow syntax, then add loops, alt blocks, and activation as needed.
[Try it now in our free Mermaid Live Editor →](/)
### Mermaid Gantt Chart: Examples & Best Practices
URL: https://mermaideditor.lol/blog/mermaid-gantt-chart-examples
Published: 2025-12-12
Updated: 2025-12-12
Description: Create Gantt charts with Mermaid.js for project planning. Learn task syntax, dependencies, milestones, sections, and date formatting with practical examples.
## Introduction to Mermaid Gantt Charts
Gantt charts visualize project schedules — showing tasks, durations, dependencies, and milestones on a timeline. While dedicated project management tools like Jira or MS Project offer interactive Gantt charts, Mermaid lets you create them as code that lives in your documentation.
This is perfect for README files, design docs, and technical proposals where you need a visual timeline without the overhead of a separate tool.
## Basic Gantt Syntax
```
gantt
title My Project Plan
dateFormat YYYY-MM-DD
section Planning
Requirements gathering :a1, 2025-01-01, 7d
System design :a2, after a1, 5d
section Development
Backend implementation :b1, after a2, 14d
Frontend implementation :b2, after a2, 10d
section Testing
Integration testing :c1, after b1, 5d
UAT :c2, after c1, 3d
```
### Key Elements
- **`title`** — Chart title
- **`dateFormat`** — How dates are parsed (YYYY-MM-DD is standard)
- **`section`** — Groups related tasks
- **Tasks** follow the format: `Task name : id, start, duration`
## Task Definition Formats
Tasks can be defined in several ways:
```
gantt
dateFormat YYYY-MM-DD
section Various Formats
Fixed dates :t1, 2025-03-01, 2025-03-10
With duration :t2, 2025-03-01, 10d
After dependency :t3, after t1, 5d
No ID needed :2025-03-15, 7d
```
### Duration Units
- `d` — days (most common)
- `h` — hours
- `m` — minutes
- `w` — weeks
## Task States
Tasks can have different visual states:
```
gantt
dateFormat YYYY-MM-DD
section Task States
Completed task :done, t1, 2025-01-01, 5d
Active task :active, t2, after t1, 5d
Future task :t3, after t2, 5d
Critical task :crit, t4, after t3, 3d
Critical & active :crit, active, t5, after t4, 3d
```
- **`done`** — Shown as completed (usually gray)
- **`active`** — Currently in progress (highlighted)
- **`crit`** — Critical path (usually red)
- These can be combined: `crit, done` or `crit, active`
## Milestones
Mark key dates with zero-duration milestones:
```
gantt
dateFormat YYYY-MM-DD
section Sprint 1
User stories :s1, 2025-01-06, 10d
Sprint 1 review :milestone, m1, after s1, 0d
section Sprint 2
Development :s2, after m1, 10d
Sprint 2 review :milestone, m2, after s2, 0d
section Release
Release prep :r1, after m2, 3d
Go live :milestone, m3, after r1, 0d
```
## Dependencies
Tasks can depend on one or more previous tasks:
```
gantt
dateFormat YYYY-MM-DD
section Backend
API design :api, 2025-02-01, 5d
Database schema :db, 2025-02-01, 3d
API development :apidev, after api db, 10d
section Frontend
UI mockups :ui, 2025-02-01, 7d
Frontend dev :fedev, after ui apidev, 10d
section QA
Testing :test, after fedev, 5d
```
Notice `after api db` — the task starts after BOTH `api` and `db` are complete.
## Practical Example: Software Release Plan
```
gantt
title Q1 2025 Release Plan
dateFormat YYYY-MM-DD
axisFormat %b %d
section Discovery
User research :done, ur, 2025-01-06, 10d
Competitive analysis :done, ca, 2025-01-06, 7d
Requirements doc :done, rd, after ur ca, 5d
Requirements sign-off :milestone, done, ms1, after rd, 0d
section Design
Architecture design :done, ad, after ms1, 7d
UI/UX design :active, ux, after ms1, 10d
Design review :milestone, ms2, after ad ux, 0d
section Development
Backend services :be, after ms2, 15d
Frontend application :fe, after ms2, 15d
API integration :int, after be, 5d
section Quality
Unit testing :ut, after be fe, 5d
Integration testing :it, after int ut, 5d
Performance testing :crit, pt, after it, 3d
Security audit :crit, sa, after it, 3d
section Release
Staging deployment :stg, after pt sa, 2d
UAT :uat, after stg, 5d
Production deployment :milestone, crit, prod, after uat, 0d
```
## Date Formatting
### Input Date Format
Control how Mermaid parses your dates:
```
gantt
dateFormat DD-MM-YYYY
task1 :01-03-2025, 10d
```
Common formats:
- `YYYY-MM-DD` — ISO standard (recommended)
- `DD-MM-YYYY` — European
- `MM-DD-YYYY` — US
### Axis Display Format
Control how the timeline axis looks:
```
gantt
dateFormat YYYY-MM-DD
axisFormat %Y-%m-%d
section Tasks
Task 1 :2025-01-01, 30d
```
Common axis formats:
- `%Y-%m-%d` — 2025-01-15
- `%b %d` — Jan 15
- `%d/%m` — 15/01
- `%B %Y` — January 2025
## Excluding Dates
Skip weekends or holidays:
```
gantt
dateFormat YYYY-MM-DD
excludes weekends
section Development
Task 1 :t1, 2025-03-03, 5d
Task 2 :t2, after t1, 5d
```
With weekends excluded, a 5-day task truly means 5 business days.
You can also exclude specific dates:
```
excludes weekends, 2025-12-25, 2025-12-26
```
## Sections as Swim Lanes
Use sections to organize by team, phase, or component:
```
gantt
title Cross-Team Project
dateFormat YYYY-MM-DD
section Team Alpha
Feature A :a1, 2025-03-01, 14d
Feature B :a2, after a1, 7d
section Team Beta
Feature C :b1, 2025-03-01, 10d
Feature D :b2, after b1, 10d
section Team Gamma
Feature E :g1, 2025-03-08, 14d
Integration :g2, after a2 b2 g1, 5d
```
## Best Practices
1. **Use ISO date format** (`YYYY-MM-DD`) — it's unambiguous and sorts correctly.
2. **Give tasks meaningful IDs** — `api_design` is clearer than `a1` when reading dependencies.
3. **Mark the critical path** — use `crit` on tasks that directly impact the delivery date.
4. **Use milestones** for key dates — they provide clear visual checkpoints.
5. **Exclude weekends** with `excludes weekends` for realistic business-day planning.
6. **Keep sections logical** — group by team, phase, or component. Don't mix organizational patterns.
7. **Update the `done`/`active` states** as work progresses — this makes the chart a living document.
8. **Add `axisFormat`** to make the timeline readable. `%b %d` (Jan 15) is usually the best balance of information and space.
## Limitations
- Mermaid Gantt charts are **read-only** — you can't drag tasks or interact with them.
- Complex projects with hundreds of tasks are better served by dedicated PM tools.
- Resource assignment and workload balancing aren't supported.
- The layout engine may struggle with many overlapping dependencies.
Mermaid Gantt charts shine for **documentation** — embedding a project timeline in a README, proposal, or design doc where the audience needs to understand the plan but doesn't need to interact with it.
## Conclusion
Mermaid Gantt charts turn project timelines into maintainable code. They're perfect for technical documentation, sprint planning overviews, and release plans that live alongside your source code. Start simple with sections and tasks, then add dependencies, milestones, and critical path markers as your planning matures.
[Try it now in our free Mermaid Live Editor →](/)
### Mermaid Class Diagrams for UML — Developer Guide
URL: https://mermaideditor.lol/blog/mermaid-class-diagram-uml
Published: 2025-12-15
Updated: 2025-12-15
Description: Create UML class diagrams with Mermaid.js. Learn classes, attributes, methods, relationships, inheritance, interfaces, and design patterns with examples.
## What Are Class Diagrams?
Class diagrams are the backbone of UML (Unified Modeling Language) and the most common diagram for modeling object-oriented systems. They show classes, their attributes and methods, and the relationships between them.
Mermaid lets you create class diagrams from text, making them perfect for documenting codebases, planning architectures, and communicating designs in pull requests.
## Basic Class Syntax
```
classDiagram
class Animal {
+String name
+int age
+makeSound() void
+move(distance) void
}
```
### Visibility Modifiers
Mermaid follows UML conventions:
- `+` Public
- `-` Private
- `#` Protected
- `~` Package/Internal
```
classDiagram
class User {
+String username
-String passwordHash
#String email
~int loginAttempts
+login(password) bool
-hashPassword(raw) String
#validateEmail() bool
}
```
## Relationships
### Inheritance (Generalization)
```
classDiagram
Animal <|-- Dog
Animal <|-- Cat
Animal <|-- Bird
class Animal {
+String name
+makeSound() void
}
class Dog {
+fetch() void
}
class Cat {
+purr() void
}
class Bird {
+fly() void
}
```
### All Relationship Types
```
classDiagram
classA <|-- classB : Inheritance
classC *-- classD : Composition
classE o-- classF : Aggregation
classG --> classH : Association
classI -- classJ : Link
classK ..> classL : Dependency
classM ..|> classN : Realization
```
**When to use each:**
- **Inheritance** (`<|--`): "is a" — Dog is an Animal
- **Composition** (`*--`): "owns, can't exist without" — Car owns Engine
- **Aggregation** (`o--`): "has, can exist independently" — Department has Employees
- **Association** (`-->`): "uses" — Order references Customer
- **Dependency** (`..>`): "temporarily uses" — Service depends on Logger
- **Realization** (`..|>`): "implements" — UserService implements IUserService
## Cardinality (Multiplicity)
Show how many instances relate:
```
classDiagram
Customer "1" --> "*" Order : places
Order "1" --> "1..*" OrderItem : contains
OrderItem "*" --> "1" Product : references
```
Common multiplicities:
- `1` — exactly one
- `0..1` — zero or one
- `*` or `0..*` — zero or more
- `1..*` — one or more
## Interfaces and Abstract Classes
```
classDiagram
class IRepository {
<