---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://excalidraw.heycactus.ai/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
lang: en
---

# Text to diagram

Text to diagram draws a diagram on the canvas from a written idea or from Mermaid code. The Excalidraw web app has a **Text to diagram** tab that writes the diagram from your prompt, and a **Mermaid** tab that draws the code you type. Both open from **More tools**, under **Generate**, in the toolbar.

> Verified against the product on 2026-11-23

## Who can use it

The **Text to diagram** tab is in the Excalidraw web app. The **Mermaid to Excalidraw** item opens the **Mermaid** tab, and both sit under **Generate** in the toolbar's **More tools** menu. The **Text to diagram** item is hidden when AI is turned off. Where the editor has no text-to-diagram dialog of its own, the dialog opens as **Mermaid to Excalidraw** with its code box and no tabs.

## Generate a diagram from a prompt

1. Open **More tools** in the toolbar, then select **Text to diagram** under **Generate**. The tab carries an **AI Beta** badge.
2. Type your idea in the box and press Enter. Press Shift + Enter for a new line. In an empty chat the box reads “Start typing your diagram idea here... (Shift + Enter for new line)”.
3. While the reply comes in, the box reads “Generating...” and the send button becomes a stop icon, with no label. Select it to stop the reply. A stopped reply shows no error.
4. Once the chat has a reply, its diagram is previewed beside the chat. Select **Insert** in the preview to add it to the canvas.

The diagram is added at the center of the canvas, scaled down to fit, and the dialog closes.

Each reply also has an **Insert** icon, which adds that reply's diagram the same way. The icon is hidden on a reply that failed.

To edit a reply's code, select **View as Mermaid**. It opens the code in the **Mermaid** tab.

## Draw Mermaid code

1. Open **More tools** and select **Mermaid to Excalidraw** under **Generate**. The tab is called **Mermaid**.
2. Type or paste Mermaid code in the box. The preview draws it as you type.
3. Select **Insert**. In the plain text box, Ctrl or Cmd with Enter also inserts.

> **Note:** Insert adds the last diagram that drew without an error. While the code has an error, it adds the diagram from before the error.

The box keeps the code in this browser. It saves after you stop typing and when you leave the page. If nothing is saved, the box starts with a sample flowchart.

Five kinds of diagram are drawn: flowcharts, sequence diagrams, class diagrams, state diagrams and entity relationship diagrams. Each starts with its own first line, such as `flowchart TD` or `erDiagram`. Flowcharts are drawn with elbow arrows.

## Your chats stay in this browser

Chats are saved in this browser. Only the 10 most recent chats are kept. A chat is saved when a reply finishes and when you start a new one. Its title is the first prompt, cut to 47 characters and followed by “...” when it is longer than 50 characters.

- **New Chat** starts an empty chat. It shows once the chat has messages, and it is off while a reply is generating.
- The button titled **Menu** lists your saved chats. It shows once a chat is saved.
- Select a chat in that list to reopen it.
- Each chat has a trash icon titled **Delete chat**. Deleting the open chat opens the newest of the others, or an empty chat when none are left.

## Prompt and request limits

- A prompt is 3 to 10,000 characters.
- _count_ requests left today shows how many requests are left today.
- The count shows as a warning below 5 left.
- At 0 left, the box is disabled and reads “You've reached your message limit”. Sending is off, and so is the **Regenerate (auto-fix) →** button.

## If a reply or diagram fails

| What you see | What it means | What to do |
| --- | --- | --- |
| “Prompt is too short (min 3 characters)” | Your prompt has fewer than 3 characters. | Type a longer prompt. |
| “Prompt is too long (max 10000 characters)” | Your prompt is longer than 10,000 characters. | Shorten the prompt. |
| “Generated an invalid diagram :(. You may edit manually, retry with auto-fix, or try a different prompt.” with **Edit Mermaid manually →** and **Regenerate (auto-fix) →** | The latest reply is not valid Mermaid, so it can't be drawn. | Select **Edit Mermaid manually →** to open its code in the **Mermaid** tab. Or select **Regenerate (auto-fix) →** to ask the AI to fix it. |
| “Request failed”, or the message the AI service sends | The request did not finish. | Select **Retry** under the reply. It turns on 5 seconds after the last try and sends your last prompt again. |
| “Generation failed” | The request failed and no reply came back. | Send the prompt again. |
| “Hold your horses, you're too fast for us! Please wait a moment before trying again.” | You sent requests too fast, or the service refused one as too many. The last reply is removed. | Wait a moment, then send again. |
| “You've hit your AI limit on the free plan. Try out Excalidraw+ for more or come back tomorrow.” with **Upgrade to Plus** | No requests are left. | Come back tomorrow, or select **Upgrade to Plus**, which opens the Excalidraw+ page in a new tab. |

| What you see | What it means | What to do |
| --- | --- | --- |
| “Syntax error near line _N_.” or “Syntax error in Mermaid diagram.”, with “Likely causes:” | The Mermaid code can't be read. The list gives the likely causes. | Fix one of the causes listed. If **Auto-fix is available** appears, select it. |
| “Unknown diagram type.” | The first line does not name a diagram type. | Start with `flowchart TD`, `sequenceDiagram`, `classDiagram`, `stateDiagram-v2` or `erDiagram`. |
| **Auto-fix is available** | A changed version of the code draws. | Select it to replace the code with that version. |
| “Couldn't load Mermaid. Check your internet connection and try again.” with **Retry** | The converter did not load, for example because you are offline. | Select **Retry**. The box also retries when you are back online. |
| “Couldn't load Mermaid. Reload the page to try again.” with **Reload** | The converter failed to load while you were online, so a reload is needed. | Select **Reload**. |

## Related pages

- [Canvas and toolbar](https://excalidraw.heycactus.ai/tqp2n6-canvas-and-toolbar)
- [Excalidraw web app](https://excalidraw.heycactus.ai/4y3cgx-excalidraw-web-app)
- [Excalidraw React component](https://excalidraw.heycactus.ai/9hsu3k-excalidraw-react-component)
- [Arrows](https://excalidraw.heycactus.ai/9ugruv-arrows)
