Using Mermaid Diagrams in Documentation

From ASCII art to Mermaid: A better way to create technical diagrams

From ASCII Art to Mermaid

For the first 12 years of my career, most of my work was using a terminal and vi editor. Many of the design documents were simple text files, or just direclty documented in code. ASCII art was the to draw diagrams, and it was great. Simple illustrations. At one of the startups I worked at, we maintained all our design diagrams in text files—there was no other option. This wasn’t just a preference; it was the reality of working in Unix environments where everything was text-based, version-controlled, and had to work over SSH connections.

I’d spend hours on asciiflow.com, carefully drawing boxes and arrows with text characters,trying to make them look somewhat professional. The results were functional but fragile—one character misaligned and the whole diagram fell apart. Sharing them in markdown files or design docs worked, but editing them was always a pain.

+----------------+      +------------------+
|    Browser     |----->|   Web Server     |
+----------------+      +------------------+
                               |
                               v
                        +-------------+
                        |  Database   |
                        +-------------+

Recently, I discovered Mermaid, and it’s changed how I think about diagrams in documentation. Instead of drawing with characters, you write code that describes the diagram. The syntax is clean, the diagrams look professional, and best of all—they’re easy to edit and version control. Plus, they automatically adapt to light and dark themes on my blog.

Here’s that same diagram in Mermaid:

graph LR Browser -->|HTTP| WebServer[Web Server] WebServer --> Database

Let me show you what’s possible with Mermaid.

System Architecture Example

graph TB User[User Browser] -->|HTTPS| CDN[Cloudflare CDN] CDN -->|Cache Miss| Netlify[Netlify Hosting] Netlify -->|Static Files| Hugo[Hugo Generated Site] Hugo -->|Markdown| Content[Content Files] Hugo -->|Templates| Theme[Stack Theme] Hugo -->|Assets| CSS[SCSS/CSS] style User fill:#5fb878 style CDN fill:#f9a825 style Netlify fill:#00c7b7 style Hugo fill:#ff4088

Sequence Diagram Example

Here’s how a typical request flows through the system:

sequenceDiagram participant User participant CDN as Cloudflare CDN participant Host as Netlify participant Git as GitHub User->>CDN: Request page CDN->>CDN: Check cache alt Cache Hit CDN->>User: Return cached page else Cache Miss CDN->>Host: Request page Host->>User: Return fresh page CDN->>CDN: Cache page end Note over Git,Host: On git push Git->>Host: Trigger build Host->>Host: Run Hugo build Host->>CDN: Invalidate cache

Flowchart Example

Decision flow for publishing content:

flowchart TD Start([Write Draft]) --> Review{Review Complete?} Review -->|No| Edit[Make Edits] Edit --> Review Review -->|Yes| Diagrams{Add Diagrams?} Diagrams -->|Yes| Mermaid[Create Mermaid Diagrams] Mermaid --> Publish Diagrams -->|No| Publish[Publish Post] Publish --> Share[Share on Social Media] Share --> End([Done]) style Start fill:#5fb878 style End fill:#5fb878 style Publish fill:#ff4088

Class Diagram Example

For documenting system components:

classDiagram class BlogPost { +String title +String content +Date published +String[] tags +String category +render() +publish() } class Diagram { +String type +String code +render() } class Theme { +String name +loadCSS() +loadJS() } BlogPost "1" --> "0..*" Diagram BlogPost --> Theme

Git Graph Example

Visualizing branching and merging:

gitGraph commit id: "Initial commit" commit id: "Add blog structure" branch feature checkout feature commit id: "Add Mermaid support" commit id: "Create About page" checkout main commit id: "Fix search bug" checkout feature commit id: "Test diagrams" checkout main merge feature commit id: "Deploy to production"

State Diagram Example

Perfect for modeling state machines and workflows:

stateDiagram-v2 [*] --> Draft Draft --> Review: Submit for review Review --> Draft: Request changes Review --> Approved: Approve Approved --> Published: Publish Published --> Archived: Archive Archived --> [*] Draft: Draft Post Review: In Review Approved: Approved Published: Published Archived: Archived note right of Review Editors review content for quality and accuracy end note

Entity Relationship Diagram

For documenting database schemas:

erDiagram USER ||--o{ POST : writes USER ||--o{ COMMENT : makes POST ||--o{ COMMENT : has POST }o--o{ TAG : tagged_with POST }o--|| CATEGORY : belongs_to USER { int id PK string username string email datetime created_at } POST { int id PK int author_id FK int category_id FK string title text content datetime published_at } COMMENT { int id PK int user_id FK int post_id FK text content datetime created_at } TAG { int id PK string name } CATEGORY { int id PK string name }

Gantt Chart Example

Great for project planning and timelines:

gantt title Blog Migration Project dateFormat YYYY-MM-DD section Planning Research static site generators :done, research, 2025-10-01, 7d Choose Hugo and theme :done, choose, 2025-10-08, 3d section Development Set up Hugo project :done, setup, 2025-10-11, 2d Migrate existing posts :done, migrate, 2025-10-13, 10d Custom theme styling :done, styling, 2025-10-23, 5d Add Mermaid support :active, mermaid, 2025-10-28, 5d section Testing Test on multiple devices :testing, 2025-11-02, 3d Performance optimization :optimize, 2025-11-05, 4d section Launch Deploy to production :deploy, 2025-11-09, 1d Monitor and fix issues :monitor, 2025-11-10, 7d

Wide Gantt Chart Example

With AI-powered development, what used to take years now takes weeks. This 90-day sprint shows how horizontal scrolling helps visualize packed timelines:

gantt title AI-Accelerated Product Development Sprint (90 Days) dateFormat YYYY-MM-DD section Week 1-2: Discovery Market Research with AI :done, 2025-01-01, 3d Competitor Analysis :done, 2025-01-04, 2d User Interviews :done, 2025-01-06, 3d Requirements Doc with Claude :done, 2025-01-09, 2d Technical Feasibility :done, 2025-01-11, 2d section Week 3-4: Design System Architecture :done, 2025-01-15, 3d Database Schema Design :done, 2025-01-18, 2d API Design :done, 2025-01-20, 2d UI/UX Mockups :done, 2025-01-22, 3d Design System Setup :done, 2025-01-25, 2d Figma to Code :done, 2025-01-27, 2d section Week 5-6: Backend Core Project Scaffolding :active, 2025-02-01, 1d Auth Service :active, 2025-02-02, 3d User Management API :active, 2025-02-05, 3d Database Migrations :active, 2025-02-08, 2d API Gateway :2025-02-10, 2d Logging & Monitoring :2025-02-12, 2d section Week 7-8: Frontend Core React Setup with Vite :2025-02-15, 1d Component Library :2025-02-16, 3d Routing & Navigation :2025-02-19, 2d State Management :2025-02-21, 2d Form Handling :2025-02-23, 2d API Integration Layer :2025-02-25, 3d section Week 9-10: Features Sprint 1 User Dashboard :2025-03-01, 3d Profile Management :2025-03-04, 2d Settings Page :2025-03-06, 2d Search Functionality :2025-03-08, 3d Notifications System :2025-03-11, 3d Real-time Updates :2025-03-14, 2d section Week 11-12: Features Sprint 2 Payment Integration :2025-03-18, 4d Subscription Management :2025-03-22, 3d Invoice Generation :2025-03-25, 2d Analytics Dashboard :2025-03-27, 3d Reporting Engine :2025-03-30, 3d Data Export :2025-04-02, 2d section Week 13-14: Advanced Features AI Chat Integration :2025-04-05, 4d File Upload & Storage :2025-04-09, 3d Image Processing :2025-04-12, 2d Email Service :2025-04-14, 2d SMS Notifications :2025-04-16, 2d Webhook System :2025-04-18, 3d section Week 15-16: Admin & Security Admin Dashboard :2025-04-22, 4d User Management Panel :2025-04-26, 3d Role-Based Access Control :2025-04-29, 3d Security Audit :2025-05-02, 2d GDPR Compliance :2025-05-04, 2d Rate Limiting :2025-05-06, 2d section Week 17-18: Testing Unit Test Coverage :2025-05-10, 4d Integration Tests :2025-05-14, 3d E2E Tests with Playwright :2025-05-17, 3d Performance Testing :2025-05-20, 2d Security Testing :2025-05-22, 2d Load Testing :2025-05-24, 2d section Week 19-20: Polish & Optimization UI Polish :2025-05-28, 3d Performance Optimization :2025-05-31, 3d Bundle Size Reduction :2025-06-03, 2d SEO Optimization :2025-06-05, 2d Accessibility Audit :2025-06-07, 2d Mobile Responsiveness :2025-06-09, 2d section Week 21-22: Deployment CI/CD Pipeline Setup :2025-06-13, 2d Staging Deployment :2025-06-15, 2d QA Testing :2025-06-17, 3d Bug Fixes :2025-06-20, 3d Production Deployment :2025-06-23, 2d Monitoring Setup :2025-06-25, 2d section Week 23-24: Launch Beta User Onboarding :2025-06-29, 3d Feedback Collection :2025-07-02, 3d Quick Iterations :2025-07-05, 3d Marketing Site :2025-07-08, 3d Documentation :2025-07-11, 3d Public Launch :2025-07-14, 1d Post-Launch Support :2025-07-15, 7d

Pie Chart Example

Useful for showing proportions and distributions:

pie title Technology Stack Distribution "Hugo (Go)" : 30 "JavaScript" : 25 "SCSS/CSS" : 20 "Markdown" : 15 "HTML Templates" : 10

Quadrant Chart Example

For categorizing items across two dimensions:

quadrantChart title Blog Post Priority Matrix x-axis Low Traffic --> High Traffic y-axis Low Effort --> High Effort quadrant-1 Plan Carefully quadrant-2 Do First quadrant-3 Maybe Later quadrant-4 Quick Wins "tmux tutorial": [0.8, 0.3] "Vim shortcuts": [0.6, 0.2] "System design series": [0.4, 0.9] "Git tips": [0.7, 0.15] "Mermaid diagrams": [0.3, 0.25] "Career advice": [0.5, 0.7]

How to Use Mermaid

To add any of these diagrams to your markdown files, just use standard code blocks with mermaid as the language:

1
2
3
4
5
```mermaid
graph TD
    A[Start] --> B[Process]
    B --> C[End]
```

The diagrams automatically adjust to match your site’s theme—light or dark mode—which is something ASCII diagrams could never do.

Why I Switched

Here’s what I appreciate about Mermaid over ASCII diagrams:

Version control friendly: Changing a diagram is as simple as editing a line of text. With ASCII art, any structural change meant redrawing half the diagram.

Consistent styling: All diagrams look professional and match each other. No more aligning boxes by hand or counting spaces.

Easy to edit: Want to add a new node? Just add a line. Want to change a relationship? Update the arrow. In ASCII, this meant shifting entire sections around.

Portable: The same Mermaid code works in GitHub, GitLab, Notion, and countless other tools. ASCII diagrams looked different everywhere depending on font rendering.

Maintainable: I can actually come back to a diagram six months later and understand how to update it. ASCII diagrams were write-only code.

For quick sketches, I still use a whiteboard or pen and paper. But for anything that goes into documentation, Mermaid has completely replaced my ASCII diagram workflow.

Resources

If you want to try Mermaid:

The learning curve is minimal—if you can write markdown, you can write Mermaid diagrams.

comments powered by Disqus

© 2025 Santosh Manoharan