Mermaid Diagram Editor with Live Preview
Write Mermaid text on the left and watch the diagram render on the right. Prettify has 16 starter templates, two diagram styles, and SVG and PNG export. Rendering happens in your browser. Paste your Mermaid below, then open the editor.
What the Mermaid editor does
Mermaid is a text format for diagrams. You describe boxes and arrows in words, and a renderer draws them. This editor splits the screen into source and preview, so each edit shows its effect.
A Mermaid document must start with a diagram keyword such as flowchart or sequenceDiagram. Blank lines, a YAML frontmatter block, and %% comment lines may come before it. The box on this page checks that first keyword and shows your text back. The drawn diagram is in the editor.
Key features
The editor covers writing, checking, styling, and exporting a diagram in one place.
- The source pane has line numbers, and the preview redraws shortly after you stop typing.
- A badge at the top left names the diagram type, and you can drag the divider to resize the panes.
- Below 768 px wide, the panes stack with the source above the preview.
- The template gallery shows 16 diagrams, each previewed in your current style and theme.
- Two styles are available: Prettify, drawn with Pele, and GitHub, drawn with Mermaid.js.
- The editor checks the keyword, the --> arrow in flowcharts, and closed brackets, and gives line numbers.
- If a diagram fails to render, the last valid diagram stays on screen next to the error.
- Export saves SVG for vector graphics or PNG at 2x scale.
How to write and export a diagram
Begin in the box if you already have Mermaid text. Otherwise skip to the editor and pick a template.
- Paste your Mermaid into the box labeled "Paste your Mermaid", or select "Try an example".
- Check the result. A valid start reads "Diagram source." If the first line is not a diagram keyword, the box says the text is not valid Mermaid.
- Select "Open in full editor". The editor opens with the source and the preview side by side.
- Edit the source on the left and watch the preview on the right.
- Select the template button in the toolbar, then select a template. It replaces the current source.
- Select the export button, then choose SVG or PNG.
- Press Cmd+S (Mac) or Ctrl+S (Windows, Linux), or select Save, to keep your edits.
Worked example: a login sequence
The first line declares a sequence diagram. The two participant lines give each lifeline a short id and a readable name. A solid arrow (->>) sends a request, and a dashed arrow (-->>) returns a reply.
The alt block splits the reply in two. One branch handles a valid login, and the else branch handles an invalid one. The block closes with end. The preview shows two lifelines, one request, and a labeled box with the two replies. A missing end is a syntax error, so the preview shows the renderer message and keeps the last good drawing.
sequenceDiagram
participant U as User
participant A as API
U->>A: POST /login
alt valid
A-->>U: 200 token
else invalid
A-->>U: 401
endErrors in flowcharts, and the two styles
In a flowchart, a line such as A -> B is an error, because the arrow must be -->. A line that opens a [ or a { and does not close it is an error too. The editor reports both with a line number. The box on this page checks only the first keyword, so use the editor to see these checks.
The Prettify style draws compact diagrams almost at once. Choose the GitHub style when the diagram must look the same as on GitHub, GitLab, or Notion. Box positions can differ between the two, because each style has its own layout. The style applies to the editor, the template previews, and Mermaid code blocks in Markdown. If Pele cannot draw a diagram, Prettify draws it in the GitHub style.
Common use cases
Diagrams as text sit well in version control and review. Typical jobs include these.
- Draw an architecture or a data flow for a README.
- Sketch an entity-relationship diagram while you design a schema.
- Plan a project with a Gantt chart or a timeline.
- Write a state machine for a feature and share the SVG.
- Test a diagram here before you paste it into a Markdown file.
Free to use, and rendered with strict security
Writing Mermaid, the live preview, the templates, and SVG and PNG export are free. Pro only applies when a Markdown document shows Mermaid code blocks as diagrams in its Preview. The renderer runs with strict security, because a diagram can come from a shared file. Click callbacks and raw HTML labels do not run, and the Prettify style loads no remote images.
Frequently asked questions
Which diagram types does it support?
It recognizes graph, flowchart, sequenceDiagram, classDiagram, stateDiagram, erDiagram, gantt, pie, gitGraph, mindmap, timeline, quadrantChart, sankey, xychart, block, journey, and architecture.
Why does my diagram look different from GitHub?
The default Prettify style uses its own layout, so box and line positions can differ. Switch to the GitHub style in Settings, under Diagrams, to match GitHub, GitLab, or Notion.
Why does the box accept my flowchart but the editor shows an error?
The box only checks that the text starts with a diagram keyword. The editor also checks arrows and brackets, and shows the renderer error. Open the editor to see the full result.
How does the image export work?
Select the export button and choose SVG or PNG. SVG keeps vector graphics. PNG is saved at 2x scale. The image background follows your theme. The desktop app opens a native save dialog, and the web app downloads the file.
Can I use Mermaid themes and init directives?
Themes set with %%{init: ...}%% or themeVariables apply only in the GitHub style. In the Prettify style, the colors follow your Prettify theme.
Does my diagram source leave my device?
No. Both styles render in your browser, and Prettify does not upload your source unless you create a share link.