# Import from draw.io, Visio, Lucidchart and more

## Agent prompt

```text
Help me complete my task in Slatebox using the official app guide. Ask which outcome I want, then walk me through the relevant steps and verify it on my slate.

Read https://docs.slatebox.com/Using-Slatebox/import-diagrams.md first. Ask for the inputs you need. Tell me what you verified and which steps I still need to do.

If your client cannot fetch the documentation, read the same published file at https://raw.githubusercontent.com/Slatebox/slatebox-docs/retype/Using-Slatebox/import-diagrams.md.
```

Bring a diagram from another tool into a slate. Its shapes become notes you can edit, with their words and colors, where they were drawn. Its connectors become lines with their labels, arrows and dashes. Containers, swimlanes, groups and clusters become frames. It is free, and no agent is involved.

Pictures are never brought in as pictures. Images, free-hand strokes and embeds are left out, and the import tells you how many.

## Import a file

1. Open **Import a diagram**: from the slate menu, from the **+** menu, or from **Create slate** (choose **Import a diagram** under the ways to start).
2. Drop a file on the dialog, or choose one. You can also paste the diagram's text (Mermaid, Graphviz, PlantUML, draw.io XML or an outline), or an excalidraw.com share link.
3. In a slate you can edit, choose **Add to this slate** or **New slate**.
4. Choose **Import**.

For a new slate you can also choose **Mark as reviewed after the import** and write what you checked: the slate is signed off as it was imported, and the record names the file and its SHA-256 hash. When something was left out, such as pictures or lines with a loose end, the dialog says what before it closes.

A new slate is private to you and is named after the diagram. Added to an open slate, the diagram is drawn to the right of what the slate holds, and everyone on the slate sees it drawn. You can undo it in one step.

Slatebox finds the format from the file's name, or from what the file holds.

| Tool | Files | What comes in |
| --- | --- | --- |
| draw.io and diagrams.net | `.drawio`, `.xml`, `.drawio.svg`, `.drawio.png` | Every page side by side, compressed or not. Shapes with their fill, border and text colors, containers and swimlanes as frames, edge labels, arrows and dashes. From a `.svg` or `.png`, only the diagram saved inside it, so export with **Include a copy of my diagram** |
| Visio | `.vsdx` | Every page. Shapes with their master's size and colors, groups as frames, connectors glued at both ends |
| Lucidchart and Lucidspark | `.vsdx` or `.csv` | Export as Visio (`.vsdx`) to keep where shapes are. The CSV export (**File › Export › CSV of shape data**) has no positions, so its shapes are laid out again, with containers as frames |
| Excalidraw | `.excalidraw`, or an excalidraw.com share link | Shapes with their fill and stroke, arrow labels, arrowheads, dashed and dotted lines, frames. The link's key stays in your browser |
| tldraw | `.tldr` | Shapes, sticky notes, text and frames with tldraw's colors, arrows bound at both ends, every page side by side |
| Graphviz | `.dot`, `.gv` | Nodes with their label, shape, fill and font color, edges with their label, direction and style, clusters as frames. Laid out again in the graph's `rankdir` |
| PlantUML | `.puml`, `.plantuml` | Component, use case, deployment, state and step-by-step activity diagrams, mind maps and work breakdowns. Laid out again. Sequence, class and Gantt diagrams are refused by name |
| Mermaid | `.mmd`, or Markdown with a Mermaid block | Flowcharts, mind maps and Gantt charts. [Export and import Mermaid](mermaid.md) |
| XMind | `.xmind` | The first sheet as a mind map, with its relationships as labeled lines |
| FreeMind and Freeplane | `.mm` | The mind map, with node colors and arrow links |
| OPML | `.opml` | The outline as a mind map. MindNode, OmniOutliner and most outliners export it |
| Markdown or text | `.md`, `.txt` | Bullets, indentation and `#` headings as a mind map |

One import takes a file of up to 5 MB, and up to 1,000 notes and 5,000 lines (a slate's own limits). A larger diagram is refused before anything is drawn: split it, or import one page or frame at a time.

Whimsical and FigJam have no diagram file export. Copy their text and paste it as an outline.

| Refusal | Why |
| --- | --- |
| `415 diagram_unsupported` | Another kind of file. An older Visio file (`.vsd`, `.vdx`): open it in Visio and save it as `.vsdx` |
| `413 diagram_too_large` | Over 5 MB, or more than a slate holds |
| `422 diagram_invalid` | A damaged file, or one that is not the format its name says |
| `422 diagram_empty` | Nothing to draw |



## Import from an exec script

Agents use the same call on every surface: the hosted MCP endpoint (the `import_diagram` tool), the `slatebox` command and `POST /api/v1/exec`. Save the script as `import.js`:

<!-- tabs -->

```js JavaScript
const drawn = await slatebox.slates.importDiagram({
  fileName: "services.dot",
  text: "digraph { rankdir=LR; web -> api -> db [label=\"SQL\"] }",
})
return { url: drawn.url, notes: drawn.notes, lines: drawn.lines, warnings: drawn.warnings }
```

```ts TypeScript
const drawn = await slatebox.slates.importDiagram({
  fileName: "services.dot",
  text: "digraph { rankdir=LR; web -> api -> db [label=\"SQL\"] }",
})
return { url: drawn.url, notes: drawn.notes, lines: drawn.lines, warnings: drawn.warnings }
```

<!-- /tabs -->

Preview it first. The Node.js and Python tabs use the `exec.mjs` and `exec.py` helpers from [Run a script](../Developers/SlateboxAPI/terminal-and-agents.md#run-a-script).

<!-- tabs -->

```sh Node.js
node exec.mjs import.js --preview
```

```sh Python
python3 exec.py import.js --preview
```

```sh CLI
npx --no-install slatebox exec import.js --remote --preview
```

<!-- /tabs -->

A preview says what would be drawn and saves nothing. Run it again without `--preview` to create the slate. Pass `shareId` to draw it on a slate you can edit.

| Call | Input | Returns |
| --- | --- | --- |
| `slatebox.slates.importDiagram` | `fileName`, and `data` (the file as base64) or `text`; `format` when the name does not say it; `shareId`, or `name` and `projectId` for a new slate | `shareId`, `url`, `format`, `notes`, `frames`, `lines`, `created`, `fileSha256`, `warnings`, `message` |

## Import over HTTP

Send the file as base64 with a token that has `slates:write`:

```sh curl
jq -n --arg data "$(base64 < diagram.drawio | tr -d '\n')" '{fileName: "diagram.drawio", data: $data}' |
curl --fail-with-body --silent --show-error \
  -H "Authorization: Bearer $SLATEBOX_API_TOKEN" -H 'Content-Type: application/json' \
  --data @- "$SLATEBOX_BASE_URL/api/v1/slates/import-diagram"
```

The answer holds the new slate's `url`. A new slate remembers the file's name and SHA-256.
