Mermaid Diagrams in VS Code
VS Code's built-in markdown preview renders Mermaid diagrams natively. For an even better experience, extensions like Mermaid Markdown Syntax Highlighting and Mermaid Chart add live editing, syntax highlighting, and export capabilities.
Step-by-Step Guide
Use the built-in markdown preview
VS Code renders Mermaid code blocks in markdown preview out of the box. Create a .md file, add a mermaid code block, and open the preview panel (Ctrl/Cmd+Shift+V).
```mermaid
flowchart TD
A[Write Code] --> B[Preview]
B --> C[Ship]
```Install Mermaid syntax highlighting
Install the 'Mermaid Markdown Syntax Highlighting' extension for proper syntax coloring in .mmd files and mermaid code blocks. This makes complex diagrams much easier to read and edit.
Install the Mermaid Chart extension (optional)
The official 'Mermaid Chart' VS Code extension by the Mermaid team adds: live preview panel, syntax validation, and cloud sync with mermaidchart.com. It's free for basic use.
Export diagrams
For quick exports, design in our editor with full theming and export controls. For CI/CD, use mermaid-cli (mmdc) to generate PNGs and SVGs from .mmd files in your build pipeline.
Tips
- •Use .mmd file extension for standalone Mermaid files — extensions recognize this
- •VS Code's markdown preview uses a slightly different renderer than GitHub — test in both
- •For large diagrams, split-panel view (editor + preview side by side) is the most productive
- •Mermaid code blocks get syntax highlighting in the markdown source with the right extension
Design Your Diagram First
Use our editor with live preview, autocomplete, and theming — then copy-paste into VS Code.
Open Editor