Skip to content
MermaidViewer

How to Generate Mermaid Diagrams with AI (Prompt Guide)

Generate Mermaid flowcharts, sequence diagrams and ER diagrams from text with AI. Prompt templates, examples, and how to refine, fix and explain diagrams with AI.

6 min readUpdated

AI models are surprisingly good at writing Mermaid. Describe what you want in plain English and MermaidViewer's AI diagram generator produces valid Mermaid code that renders instantly — then you can refine it by hand or with more instructions.

The anatomy of a good prompt

  • Diagram type — "a sequence diagram", "an ER diagram". If you don't specify, the AI picks the most suitable type.
  • Actors or entities — who or what appears in the diagram.
  • Steps and branches — the happy path plus important alternatives and errors.
  • Constraints — direction (left to right), level of detail, labels to include.

Prompt examples

GoalPrompt
FlowchartFlowchart, left to right, of our refund process: request, eligibility check, manager approval for amounts over $500, refund, email confirmation.
SequenceSequence diagram of a mobile app logging in with Google via our backend, including token refresh.
ERER diagram for a gym: members, memberships, classes, trainers, bookings, with keys.
GanttGantt chart for a 6-week website redesign starting March 2, 2026, excluding weekends.

Four AI actions in the editor

  1. Generate — create a new diagram from a description.
  2. Edit — change the current diagram with an instruction such as "add a caching layer" or "translate labels to Spanish".
  3. Fix — repair syntax errors using the parser's error message.
  4. Explain — get a plain-English explanation of a diagram, useful for reviews and accessibility.

Convert existing content

You can paste source material — SQL CREATE TABLE statements, a list of API endpoints, meeting notes or a bullet outline — and ask for the matching diagram type. This is the fastest way to document an existing system.

Free accounts get a daily AI quota; Pro raises it substantially. Anonymous visitors can try AI a few times per day without signing up.