KevsRobots Learning Platform
By Kevin McAleer, 5 Minutes
Imagine you’ve built a line-following robot and you want to explain how it works. You could open a drawing app, drag out some boxes, type in each one, draw arrows between them, line everything up… and then do it all again next week when you add an obstacle sensor.
With Mermaid you write this instead:
flowchart LR
Sensors --> Brain --> Motors
And Mermaid draws this:
flowchart LR
Sensors --> Brain --> Motors
That’s the whole idea. You describe what is in the diagram and how the parts connect, and Mermaid works out where everything goes. This is called diagrams as code: your diagram is a few lines of text, just like your program is.
Mermaid is free and open source. It’s written in JavaScript and runs in a web browser, which is why so many websites and apps can draw Mermaid diagrams without you installing anything.
README.md and it stays next to the code it describes.The trade-off is that you don’t get pixel-perfect control. Mermaid decides the layout. For explaining how something works, that’s usually exactly what you want.
Lots of tools draw Mermaid automatically when you put it inside a Markdown code block marked mermaid:
| Tool | How it works |
|---|---|
| Mermaid Live Editor | Type on the left, see the diagram on the right. Perfect for learning |
| GitHub | In READMEs, issues, pull requests, discussions and wikis |
| GitLab | In Markdown files, issues and merge requests |
| Obsidian | In any note, in reading view and live preview |
| Notion | Add a Code block and set the language to Mermaid |
| VS Code | Install a Mermaid preview extension for the Markdown preview |
| kevsrobots.com | Every diagram in this course is drawn live by Mermaid in your browser |
Versions matter a little
Mermaid gets new features regularly, and each tool updates its copy of Mermaid at its own pace. A brand-new feature might work in the Live Editor but not in an app that hasn’t updated yet. Everything in this course uses well-established syntax that works in all of the tools above.
Mermaid isn’t just flowcharts. In this course we’ll cover:
Sensors --> Brain --> Motors example above.Sensors --> Brain --> Motors --> Wheels. Watch the diagram update as you type.LR to TD. What happens?mermaidWhy: Tools only draw diagrams from code blocks marked as Mermaid. Any other code block is shown as text
Quick quiz 1 of 2
What does “diagrams as code” mean?
Quick quiz 2 of 2
Why is a Mermaid diagram easier to keep in Git than a PNG image?
You can use the arrows ← → on your keyboard to navigate between lessons.
Comments