UML Diagram Editor (Mermaid)
Create UML diagrams using Mermaid syntax with live preview, dark mode support, and professional styling.
Loading tool…
Diagrams as text: how Mermaid works
Drawing UML by dragging boxes is slow to create and slower to change: move one class and every connector needs re-routing. Diagrams-as-code flips that around. You describe the structure in a short text syntax — this class has these fields, this service calls that one, this state moves to the next — and a renderer lays it out for you. The text lives happily in Git, diffs cleanly in code review, and stays in sync with the system it documents.
Mermaid is the most widely supported of these syntaxes; GitHub, GitLab, Notion and many documentation tools render it natively. This editor runs Mermaid in your browser and supports the diagram types used most in software design: class diagrams, sequence diagrams, state diagrams, entity-relationship diagrams, flowcharts and Git graphs. The preview re-renders as you type and follows the site's light or dark theme.
Why we built this tool
Developers use it to sketch a class model before writing code, document an API call sequence in a pull request, map database tables in an ER diagram, or produce a clean image for a design document or presentation.
Architecture diagrams describe internal systems — service names, data models, integrations — that you would not paste into a stranger's server. Here, the Mermaid source is rendered in your own browser, and the SVG or PNG is generated and downloaded locally.
Tips and common mistakes
- Start from one of the examples (Class, Sequence, State, ER, Flowchart, Git) and edit it; the syntax is easier to learn by changing a working diagram.
- Keep the Mermaid source alongside your code — a .mmd file or a fenced mermaid block in a README — so the diagram is updated with the code.
- Export SVG for documents and slides, where it stays sharp at any size; use PNG where SVG is not accepted.
- If the preview stops updating, the syntax has an error; undo the last change and look for a missing arrow or bracket.
Quick start: using UML Diagram Editor (Mermaid)
- Pick an example diagram type to load a working template.
- Edit the Mermaid text in the editor; the preview updates as you type.
- Rename elements, add relationships and adjust labels until the diagram says what you need.
- Switch the site theme if you want a dark version of the diagram.
- Download the result as SVG or PNG.
Documenting the code around it? The Markdown Editor & Previewer is useful for the surrounding README, and the Online Whiteboard suits freehand sketches before you formalise them.
Why write diagrams as text
- Easy to change. Renaming a class or adding a step is a one-line edit, and the layout adjusts itself.
- Fits in version control. A diagram is a few lines of plain text, so changes show up clearly in a diff.
- Works in other places too. GitHub, GitLab, Notion, Obsidian and many documentation tools render Mermaid directly, so the same text works in a README.
Class diagrams
Class diagrams show the structure of a system: classes, what they contain, and how they relate.
classDiagram
class Order {
+int id
+Date created
+addItem(Product p)
+total() double
}
class Customer {
+String name
+String email
}
Customer "1" --> "*" Order : places
Order *-- LineItem : contains
LineItem --> Product
+ marks a public member and - a private one. A member with parentheses is a method; text after the closing parenthesis is its return type.
Relationships
| Syntax | Meaning |
|---|---|
A <|-- B |
Inheritance: B extends A |
A *-- B |
Composition: B cannot exist without A |
A o-- B |
Aggregation: A has B, which can exist alone |
A --> B |
Association |
A ..> B |
Dependency |
A ..|> B |
Realization: A implements interface B |
A --> B : label |
Any relationship, with a label |
A "1" --> "*" B |
Multiplicity on each end |
Interfaces and abstract classes
classDiagram
class PaymentGateway {
<<interface>>
+charge(int cents) bool
}
class StripeGateway
PaymentGateway <|.. StripeGateway
Sequence diagrams
Sequence diagrams show messages passing between participants over time, top to bottom.
sequenceDiagram
participant U as User
participant W as Web app
participant D as Database
U->>W: Submit form
W->>D: INSERT order
D-->>W: OK
W-->>U: Order confirmed
->> is a request and -->> (dashed) is a reply. Use loop, alt/else and opt blocks for repetition and branches:
sequenceDiagram
Client->>Server: Login
alt valid password
Server-->>Client: Token
else wrong password
Server-->>Client: 401 Unauthorized
end
State diagrams
State diagrams show the states something can be in and what moves it between them. [*] is the start or the end.
stateDiagram-v2
[*] --> Draft
Draft --> Submitted : submit
Submitted --> Approved : approve
Submitted --> Rejected : reject
Rejected --> Draft : edit
Approved --> Published
Published --> [*]
Entity-relationship diagrams
ER diagrams model database tables and how they relate. The symbols on each end of a line give the cardinality: || is exactly one, o{ is zero or more, |{ is one or more.
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
PRODUCT ||--o{ LINE_ITEM : "appears in"
CUSTOMER {
int id PK
string email
}
ORDER {
int id PK
int customer_id FK
date created
}
Flowcharts
Not strictly UML, but often what you need for a process or a use case. LR lays it out left to right; TD goes top down.
flowchart TD
A[Request received] --> B{Logged in?}
B -- yes --> C[Show dashboard]
B -- no --> D[Show login page]
D --> B
Tips
- Start small. Render after every few lines, so when something breaks you know which line did it.
- Name things the way your code does. The diagram then doubles as documentation people can search.
- One idea per diagram. Two clear diagrams beat one crowded one.
- Use SVG for documents. It stays sharp when zoomed or printed and is usually smaller than PNG.
When the diagram will not render
The editor shows Mermaid's error message under the preview. The usual causes:
| Problem | Fix |
|---|---|
| Nothing renders at all | Check the first line names a diagram type, e.g. classDiagram |
| Error near a label | Wrap labels containing spaces or symbols in double quotes |
| Unexpected arrow error | Compare the arrow with the tables above; sequence and class arrows differ |
| A word breaks the diagram | Words like end are reserved; rename the node or put it in quotes |
The Mermaid documentation covers every diagram type in full, including pie charts, Gantt charts, timelines and mind maps, which the editor also renders.
Frequently asked questions
Which diagram types can I create?
Class, sequence, state, entity-relationship (ER), flowchart and Git graph diagrams, all written in Mermaid syntax.
Can I use the diagrams on GitHub?
Yes. GitHub renders Mermaid natively, so you can paste the same text into a fenced mermaid code block in a README, issue or pull request.
What export formats are available?
SVG, which scales without blurring, and PNG for places that do not accept SVG.