Render Mermaid Code from ChatGPT, Claude or Gemini
AI assistants often answer with a Mermaid code block that the chat itself cannot draw. Paste it into the playground below to see the diagram, or open it in the editor to fix errors with AI and export it.
Try it
Edit the code; the preview updates as you type.
Rendering diagram…
How to view a Mermaid diagram from ChatGPT
- Ask the assistant to answer in Mermaid, for example: “Draw our signup flow as a Mermaid flowchart.”
- Copy the code block. The ```mermaid fence can stay; the preview ignores a fence that wraps the whole code.
- Paste it into the playground on this page, replacing the example. The diagram renders as soon as you stop typing.
- Edit labels or structure directly in the code, then export a PNG, SVG or PDF, or copy a share link.
Prompts that produce valid Mermaid
Being explicit about the diagram type and the output format avoids most errors. These prompts work with ChatGPT, Claude, Gemini and Copilot:
- Draw [process] as a Mermaid flowchart TD. Output only Mermaid code, with labels in double quotes.
- Turn this API description into a Mermaid sequenceDiagram with one participant per service: [paste].
- Convert these CREATE TABLE statements into a Mermaid erDiagram with PK and FK markers: [paste].
- Make a Mermaid gantt chart for this plan, using dateFormat YYYY-MM-DD and after dependencies: [paste].
- Summarize these notes as a Mermaid mindmap with one root and at most three levels: [paste].
Common problems in AI-generated Mermaid
| Symptom | Fix |
|---|---|
Parse error on a label | The label contains brackets or punctuation. Wrap it in double quotes: A["Pay (card)"]. |
Curly quotes “ ” | Some chats convert quotes to typographic ones. Replace them with straight double quotes. |
A node called end | Lowercase end is reserved in flowcharts. Rename it to End or Finish. |
Mixed syntax | The answer mixes flowchart arrows into a sequence diagram or similar. Ask for one diagram type only. |
Unknown diagram type | Very new types need a recent renderer. This editor runs Mermaid 11, which supports architecture, kanban, packet and radar diagrams. |
Text before the code | Copy only the code block, not the explanation around it. |
Fix errors with your own AI key
In the editor, when the preview shows a syntax error, the optional AI assistant can repair it: click Fix with AI under the error. It sends the code and the error message straight from your browser to the provider you choose, using your own OpenAI, Anthropic or DeepSeek API key.
The assistant is asked to change as little as possible, and nothing is applied until you click Apply to Editor.
Privacy
Pasted code is rendered in your browser and is not sent to this site’s servers, which matters when the diagram describes internal systems. Share links carry the code inside the link itself.
The example in the playground
This is the code the playground starts with, exactly as an AI assistant might return it, including the Markdown fence.
```mermaid
flowchart TD
Q[Ask the AI for a diagram] --> C[Copy the Mermaid code]
C --> P[Paste it here]
P --> V{Renders?}
V -->|Yes| E[Export PNG, SVG or PDF]
V -->|No| F[Fix the reported line]
F --> V
```Frequently asked questions
Why doesn’t ChatGPT show the diagram?
Most chat apps display Mermaid as plain code. You need a Mermaid renderer, such as this editor, GitHub, GitLab or Notion, to turn the code into a diagram.
Do I need to remove the ```mermaid fence?
No. If the fence wraps the whole code, the preview ignores it. Text outside the code block should be removed.
Can I ask the AI to update the diagram later?
Yes. Copy the current code from the editor back into the chat and describe the change. Or use the built-in AI assistant with your own API key.
Does this work with Claude, Gemini and Copilot?
Yes. Mermaid is a standard text format, so code from any assistant renders the same way.