Technical documentation is only as good as its visuals. For years, developers have struggled with GUI-based diagramming tools that produce static images which rot the second a line of code changes. Enter Mermaid.js: the industry-leading diagrams-as-code framework that allows you to build professional flowcharts using simple Markdown-like text.
In this guide, we'll walk through everything you need to know to master Mermaid flowcharts—from basic node connections to advanced subgraph logic and custom styling.
1. The Foundation: Basic Flowchart Orientation
Every Mermaid flowchart starts with the graph or flowchart keyword, followed by the direction of the flow. Choosing the right orientation is the first step toward a readable diagram.
flowchart TD
Start --> Process
Process --> End
Common orientations supported by our free Mermaid live editor include:
- TD: Top Down (Standard hierarchy)
- BT: Bottom Top
- LR: Left Right (Best for timelines)
- RL: Right Left
2. Working with Node Shapes and Links
Nodes aren't just boxes. You can use different brackets to represent specific logic types:
[Text]: Standard rectangle(Text): Rounded corners (Process){Text}: Diamond (Decision)((Text)): Circle (Event)[[Text]]: Subroutine
flowchart LR
A[Request] --> B{Is Authorized?}
B -- Yes --> C[Fetch Data]
B -- No --> D[Error 401]
3. Mastering Subgraphs for Complexity
As your architecture grows, so will your diagram. Subgraphs allow you to group related nodes logically, making dense maps much easier to digest for your team. This is particularly useful for modeling microservices or multi-tier cloud architectures.
flowchart TD
subgraph Client
UI --> API_Client
end
subgraph Server
API_Client --> Controller
Controller --> Service
end
4. Styling Your Diagrams (Topological Branding)
Marmady supports the full range of Mermaid styling options. Use classDef to create a look that matches your company's branding or to highlight critical paths in a network diagram.
flowchart TD
A[Normal Node]
B(Critical Error)
classDef error fill:#f96,stroke:#333,stroke-width:4px;
class B error;
Conclusion
Mastering the Mermaid syntax guide is a superpower for modern developers. It ensures that your documentation remains as dynamic as your code. Start using our Mermaid live editor online today to turn your technical thoughts into beautiful, maintainable visuals.