/drawio:drawiofrom draw.io
Generates draw.io diagrams as .drawio files from Mermaid or XML, with optional ELK layout and export to PNG/SVG/PDF. Use when creating flowcharts, architecture diagrams, ERDs, wireframes, or UI sketches.
Ships in draw.io. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Generate draw.io diagrams as native .drawio files. Author each diagram either as Mermaid (concise text that draw.io converts to editable shapes and connectors and lays out) or as draw.io XML directly. Optionally auto-layout XML with ELK, export to PNG/SVG/PDF with the diagram XML embedded (so the file stays editable in draw.io), or open the diagram in the draw.io editor through a browser URL.
Inline viewer first. This skill writes files and opens them with a shell command. If the draw.io MCP server's create_diagram tool is available in a chat that shows diagrams inline (VS Code's or Cursor's own chat, Claude.ai, ChatGPT), and the user hasn't asked for a .drawio file, an export or a URL, call create_diagram instead: the diagram appears in the conversation, with no file and no shell command. Claude Code, Codex and Copilot CLI don't show diagrams inline, not even in their VS Code or JetBrains extensions: there create_diagram only returns a link, so use this skill.
Converted Mermaid is a native .drawio file, laid out automatically, which is far more reliable than hand-positioning cells in XML.
| Author as | Best for | Needs |
|---|---|---|
| Mermaid | Flowcharts, sequence, class, state, ER, gantt, mindmap, timeline, user journey, quadrant, C4, git graph, pie, and other standard types | The desktop CLI, or an installed Chrome, Edge or Chromium, to convert it |
| XML | Custom styling, precise/hand positioning, specific shape libraries (AWS, Azure, network, UML detail…) | Nothing (optional ELK --layout needs the CLI) |
.drawio file or a url). For XML the CLI can apply an ELK auto-layout instead of you computing coordinates.If you're unsure whether the desktop CLI is present, detect it first (see Locating the CLI).
Every diagram becomes a native .drawio file first, then is delivered in the requested output format, whether you authored Mermaid or XML.
.drawio
.mmd file, then convert it with the CLI:
drawio -x -f xml -o diagram.drawio diagram.mmd
Without the CLI, the skill's script converts it with draw.io's converter in an installed Chrome, Edge or Chromium (Node.js 18+, network; the Mermaid stays local):
node <skill-folder>/scripts/mermaid-to-drawio.js diagram.mmd
Delete the .mmd afterward — the .drawio is the artifact.diagram.drawio (see XML format), then run the repair pass on it. Optionally apply an ELK layout.diagram.drawio and open it..drawio with embedded XML, then delete the source .drawio:
drawio -x -f png -e -b 10 -o diagram.drawio.png diagram.drawio
.drawio XML, open it, and keep the .drawio as a local copy (see Browser URL output)..drawio (see Opening the result). If the open command fails, print the absolute path (or URL) so the user can open it manually.Always convert Mermaid to .drawio first, then export: direct .mmd → PNG with -e crashes in current draw.io Desktop.
If the script finds no browser (exit code 3), node <skill-folder>/scripts/mermaid-to-drawio.js --link diagram.mmd prints an app.diagrams.net URL that converts the Mermaid when opened: deliver that for url or no format, saying there is no local file. For a file or an export, author the same diagram as XML. PNG, SVG and PDF need the desktop CLI either way.
The CLI's --layout step auto-positions XML-authored diagrams with the same ELK layouts as the editor's Arrange ▸ Layout menu and the draw.io MCP app server. Generate the cells with approximate (or even 0,0) positions and get the graph structure — nodes and edges — right. Use verticalFlow / horizontalFlow for flow-style diagrams and organic for networks. Mermaid-authored diagrams are already laid out — don't add --layout.
Lay out in place after you write the file (reading and overwriting the same path is supported), or combine layout with export in one call:
drawio -x -f xml --layout verticalFlow -o diagram.drawio diagram.drawio
drawio -x -f png -e -b 10 --layout verticalFlow -o diagram.drawio.png diagram.drawio
| Name | Layout |
|---|---|
verticalFlow | Layered, top-to-bottom — flowcharts, pipelines |
horizontalFlow | Layered, left-to-right |
verticalTree | Tree, top-down — hierarchies, org charts |
horizontalTree | Tree, left-to-right |
radialTree | Radial tree |
organic | Force-directed — networks, mind-map-like graphs |
For finer control, pass a JSON array (starting with [) instead of a preset name — the format of the editor's custom-layout dialog:
drawio -x -f xml --layout '[{"layout":"elkLayered","config":{"elk.direction":"RIGHT"}}]' -o diagram.drawio diagram.drawio
Each entry is {"layout": <algorithm>, "config": { … }}. Algorithms: elkLayered, elkTree, elkRadial, elkOrganic, elkStress, elkBox. Config entries starting with elk. are ELK options, e.g. elk.direction (UP / DOWN / LEFT / RIGHT), elk.spacing.nodeNode, elk.layered.spacing.nodeNodeBetweenLayers; edgeStyle (e.g. orthogonal) and corners (e.g. rounded) control connector rendering.
--layout libavoid routes the edges orthogonally around the shapes (Arrange ▸ Layout ▸ Orthogonal Routing) without moving any vertex. Run it in place on hand-positioned XML whose connectors cross shapes; skip it after a flow/tree preset, which already routes its edges:
drawio -x -f xml --layout libavoid -o diagram.drawio diagram.drawio
When authoring Mermaid, fetch and follow the shared Mermaid reference (all supported diagram types plus flowchart styling — style, classDef, linkStyle):
https://raw.githubusercontent.com/jgraph/drawio-mcp/main/shared/mermaid-reference.md
Match the language of the diagram labels to the user's language.
Check the user's request for a format preference. Examples:
/drawio:drawio create a flowchart → Mermaid → flowchart.drawio/drawio:drawio png flowchart for login → Mermaid → login-flow.drawio.png/drawio:drawio svg: ER diagram → Mermaid → er-diagram.drawio.svg/drawio:drawio pdf AWS architecture overview → XML (needs AWS shapes) → architecture-overview.drawio.pdf/drawio:drawio url flowchart for user login → opens browser at app.diagrams.net with the diagram, keeps login-flow.drawio locallyIf no format is mentioned, produce the .drawio file and open it; the user can ask to export later.
PNG, SVG and PDF are exported with -e (--embed-diagram): the file contains the full diagram XML, so opening it in draw.io recovers the editable diagram. jpg is lossy and can't embed the XML.
For url format, keep the .drawio file on disk as the user's local copy, compress its XML with Node.js's built-in zlib into a https://app.diagrams.net/#R... URL, and open that in the default browser — no draw.io Desktop needed to view it.
Run this node -e one-liner to read the .drawio file and print the URL (replace DIAGRAM.drawio with the actual filename):
URL=$(node -e '
const fs = require("fs");
const zlib = require("zlib");
const xml = fs.readFileSync(process.argv[1], "utf8");
const compressed = zlib.deflateRawSync(encodeURIComponent(xml)).toString("base64");
console.log("https://app.diagrams.net/?grid=0&pv=0&border=10&edit=_blank#R" + encodeURIComponent(compressed));
' "DIAGRAM.drawio")
This is the MCP Tool Server's XML link format. Don't use a #create= URL for XML: draw.io rewrites that hash after loading it, and when the rewrite differs from the link (it does for Node's zlib output, which isn't byte-identical to draw.io's pako) it asks "All changes will be lost!".
| Environment | Command |
|---|---|
| macOS | open "$URL" |
| Linux (native) | xdg-open "$URL" |
| WSL2 | Write a temp .url file, open via cmd.exe (see below) |
| Windows (native) | Write a temp .url file, open via start (see below) |
cmd.exe's start command treats & as a command separator and strips everything after #, which is where the diagram lives, so on Windows and WSL2 put the URL in a .url shortcut file instead.
WSL2:
TMPFILE=$(mktemp --suffix=.url)
printf '[InternetShortcut]\r\nURL=%s\r\n' "$URL" > "$TMPFILE"
cmd.exe /c start "" "$(wslpath -w "$TMPFILE")"
Windows (native): do not build the .url file with echo URL=%URL% — the & characters (?grid=0&pv=0&...) cut the shortcut short and the diagram is lost. Let Node write the file and open only its path, which never contains &:
TMPFILE=$(node -e '
const fs = require("fs");
const os = require("os");
const path = require("path");
const p = path.join(os.tmpdir(), "drawio.url");
fs.writeFileSync(p, "[InternetShortcut]\r\nURL=" + process.argv[1] + "\r\n");
process.stdout.write(p);
' "$URL")
cmd.exe /c start "" "$TMPFILE"
Then print the URL and the local file so the user can share or re-edit it:
Opened in browser: <URL>
Local file: DIAGRAM.drawio
Very large diagrams may exceed the browser's URL length limit (roughly 32K–2MB depending on the browser); then open the .drawio file locally instead.
The draw.io desktop app's command-line interface converts Mermaid to .drawio, applies ELK layouts (--layout), and exports to PNG/SVG/PDF. All three need the desktop app installed.
Detect the environment first, then locate the CLI. On Windows (native and WSL2) the installer does not put draw.io on PATH and the install directory is user-selectable, so work through the whole fallback chain before concluding the CLI is absent.
WSL2 is detected when /proc/version contains microsoft or WSL:
grep -qi microsoft /proc/version 2>/dev/null && echo "WSL2"
On WSL2, use the Windows draw.io Desktop executable via /mnt/c/...:
DRAWIO_CMD="/mnt/c/Program Files/draw.io/draw.io.exe"
Double-quote the path so the space in Program Files stays part of it. Do not wrap it in backticks — in bash that is command substitution, which would execute the binary instead of storing its path.
If draw.io is installed in a non-default location, check common alternatives:
# Default install path
"/mnt/c/Program Files/draw.io/draw.io.exe"
# Per-user install (if the above does not exist)
"/mnt/c/Users/$WIN_USER/AppData/Local/Programs/draw.io/draw.io.exe"
If neither exists, the install is on another drive or in a custom directory — scan the other mounted drives, then ask the registry:
# Program Files on the other drives (D:, E:, …)
ls /mnt/*/Program\ Files/draw.io/draw.io.exe 2>/dev/null | head -1
# Registry — the installer records the directory the user picked
for REG_PATH in 'HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall' \
'HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall' \
'HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'; do
WIN_DIR=$(reg.exe query "$REG_PATH" /s /v InstallLocation 2>/dev/null |
grep -i 'REG_SZ.*draw\.io' | head -1 |
sed 's/.*REG_SZ[[:space:]]*//' | tr -d '\r')
[ -n "$WIN_DIR" ] && DRAWIO_CMD="$(wslpath -u "${WIN_DIR%\\}")/draw.io.exe" && break
done
drawio, typically on PATH via snap/apt/flatpak — confirm with which drawiodrawio on PATH (Homebrew), /Applications, the per-user ~/Applications and Spotlight, or nothing if draw.io is absent:{ command -v drawio; ls /Applications/draw.io.app/Contents/MacOS/draw.io ~/Applications/draw.io.app/Contents/MacOS/draw.io
mdfind "kMDItemCFBundleIdentifier == 'com.jgraph.drawio.desktop'" | sed 's|$|/Contents/MacOS/draw.io|'; } 2>/dev/null | head -1
Call the binary inside the .app: a copy or symlink outside it dies with Unable to find helper app.
Check, in order — a missing PATH entry or a non-C: install drive is normal, not a sign that draw.io is missing:
where.exe draw.io (note the dot — the executable is draw.io.exe, not drawio.exe)C:\Program Files\draw.io\draw.io.exe, then the per-user install %LOCALAPPDATA%\Programs\draw.io\draw.io.exeProgram Files\draw.io\draw.io.exe on D:, E:, …Save this as find-drawio.ps1 to run the whole chain at once — it prints the first executable it finds, and nothing at all if draw.io really is not installed:
$c = @()
$c += (where.exe draw.io 2>$null)
$c += "$env:ProgramFiles\draw.io\draw.io.exe", "$env:LOCALAPPDATA\Programs\draw.io\draw.io.exe"
$c += Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -like '*draw.io*' } |
ForEach-Object { if ($_.InstallLocation) { Join-Path $_.InstallLocation 'draw.io.exe' } else { ($_.DisplayIcon -split ',')[0] } }
$c += (Get-PSDrive -PSProvider FileSystem).Root | ForEach-Object { Join-Path $_ 'Program Files\draw.io\draw.io.exe' }
$c | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1
From a bash or cmd shell, run it with:
powershell.exe -NoProfile -ExecutionPolicy Bypass -File find-drawio.ps1
Quote the resulting path on every call — it almost always contains spaces:
& "D:\Program Files\draw.io\draw.io.exe" -x -f xml -o diagram.drawio diagram.mmd
Only once every step comes up empty should you treat the CLI as absent and fall back to XML authoring with .drawio / url output. When you find it outside PATH, mention that adding its folder (e.g. D:\Program Files\draw.io) to PATH makes it discoverable next time.
drawio -x -f <format> -e -b 10 -o "<output>" "<input.drawio>"
On WSL2, call the Windows executable, e.g. "/mnt/c/Program Files/draw.io/draw.io.exe" -x -f png -e -b 10 -o "diagram.drawio.png" "diagram.drawio". The convert and layout commands are in The pipeline and ELK layout for XML.
Key flags:
-x / --export: export mode (also used for Mermaid conversion and layouts)-f / --format: output format (xml, png, svg, pdf, jpg) — use xml to produce a .drawio from Mermaid or a layout--layout: run a layout before writing the output — an ELK preset name, libavoid edge routing, or a custom-layout JSON array--mermaid-image 1: Mermaid as one static image cell instead of editable shapes — only when the user explicitly asks for that-e / --embed-diagram: embed diagram XML in the output (PNG, SVG, PDF only)-o / --output: output file path-b / --border: border width around diagram (default: 0)-t / --transparent: transparent background (PNG only)-s / --scale: scale the diagram size--width / --height: fit into specified dimensions (preserves aspect ratio)-a / --all-pages: export all pages (PDF only)-p / --page-index: select a specific page (1-based)--disable-gpu: skip GPU initialisation, when a command dies with GPU process isn't usable (see Troubleshooting)Inside VS Code (also Cursor or Windsurf, with their cursor / windsurf commands in place of code), open the file in an editor tab, next to the chat: with the Draw.io Integration extension installed, VS Code shows .drawio, .drawio.svg and .drawio.png files as editable diagrams. One command checks for the extension and otherwise falls back to the platform's command below (open on macOS):
code --list-extensions 2>/dev/null | grep -qi '^hediet.vscode-drawio$' && code <file> || open <file>
PDFs and url mode always use the platform's command:
| Environment | Command |
|---|---|
| macOS | open <file> |
| Linux (native) | xdg-open <file> |
| WSL2 | cmd.exe /c start "" "$(wslpath -w <file>)" |
| Windows | start <file> |
On WSL2, wslpath -w turns the path into a Windows path, since cmd.exe can't resolve /mnt/c/..., and the empty "" keeps start from reading the filename as a window title.
login-flow, database-schema)name.drawio.png, name.drawio.svg, name.drawio.pdf — to signal the embedded diagram XMLurl mode, keep the .drawio file (no double extension) — the URL is a view/edit handle and the local file is the persistent copyA .drawio file is native mxGraphModel XML, the same format the CLI converts Mermaid to.
Every diagram must have this structure:
<mxGraphModel adaptiveColors="auto">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
</root>
</mxGraphModel>
id="0" is the root layerid="1" is the default parent layerparent="1" unless using multiple layersparent="<container_id>" and coordinates relative to that containerparent="1". An auto-layout reads an edge's coordinates in its parent's frame, so an edge parked further out than its endpoints is laid out in the wrong place<!-- -->) in the output. They waste tokens and can cause parse errors.&, <, >, "id values for each mxCell<mxGeometry relative="1" as="geometry" /> — a self-closing edge mxCell doesn't renderRun this right after writing XML to a .drawio file, before any layout, export or URL step. It fixes the mechanical slips that make draw.io reject a diagram: text around the diagram (a code fence, a sentence, a stray closing tag), < or a stray & inside an attribute value (an unescaped HTML label, "R&D", ), and the default layer written as its own parent (<mxCell id="1" parent="1"/>, which hides everything). It changes nothing in a well-formed file, and needs only Node.js (skip it if node isn't installed). Replace DIAGRAM.drawio with the actual filename:
node -e '
const fs = require("fs");
const file = process.argv[1];
let xml = fs.readFileSync(file, "utf8");
const diagram = xml.match(/<mxfile[\s\S]*?<\/mxfile>|<mxGraphModel[\s\S]*?<\/mxGraphModel>/);
if (diagram && xml.trim() !== diagram[0]) xml = diagram[0];
xml = xml.replace(/="([^"]*)"/g, function(m, v)
{
return "=\"" + v.replace(/</g, "<").replace(/&(?!(?:amp|lt|gt|quot|apos|#[0-9]+|#x[0-9a-fA-F]+);)/g, "&") + "\"";
});
xml = xml.replace(/<mxCell id="([^"]+)" parent="\1"\s*\/>/g, "<mxCell id=\"$1\" parent=\"0\"/>");
fs.writeFileSync(file, xml);
' "DIAGRAM.drawio"
Before authoring XML, fetch and follow the condensed XML rules — skeleton, vertex and edge templates, labels, shapes, the layout grid, containers, swimlanes and edge styles: https://raw.githubusercontent.com/jgraph/drawio-mcp/main/shared/xml-essentials.md
They cover most diagrams. Only when a diagram needs layers, tags, metadata and placeholders, tables, cross-functional grids or dark-mode colors, also fetch the full XML reference (it describes the draw.io MCP servers: for their search_shapes tool use the lookup below, for postLayout / routing the CLI's --layout):
https://raw.githubusercontent.com/jgraph/drawio-mcp/main/shared/xml-reference.md
When a diagram needs cloud, network or brand icons (AWS, Azure, GCP, Cisco, Kubernetes, GitHub, Slack…), never guess mxgraph.* names: look them all up in one call to scripts/find-shapes.js in this skill's folder (Node.js 18+, network), one query per icon, narrowed by library (aws4, azure2, cisco19). It searches draw.io's shape libraries, then its icon service, and prints title width×height style lines; use a style as is:
node <skill-folder>/scripts/find-shapes.js "aws4 lambda" "github" "slack"
| Problem | Cause | Solution |
|---|---|---|
| draw.io CLI not found | Desktop app not installed or not on PATH | Work through Locating the CLI; if it's really absent, convert Mermaid with scripts/mermaid-to-drawio.js or author as XML, deliver a .drawio file or url, and tell the user that installing the draw.io desktop app enables layouts and image export |
mermaid-to-drawio.js exits with 3 | No Chrome, Edge or Chromium found, or viewer.diagrams.net unreachable | Set CHROME_PATH to the browser, or use --link or XML as in the pipeline |
| Blank diagram from Mermaid | Misspelled type keyword, or a syntax error (bad node ID, unquoted label) | Check the Mermaid reference; the first non-directive line's keyword selects the diagram type |
| Layout does nothing / errors | Unknown preset name, custom JSON not an array, or a desktop build too old for --layout / .mmd input | Use a preset or a JSON array starting with [; on an old desktop build, author as XML with explicit positions and tell the user updating draw.io Desktop enables Mermaid conversion and layouts |
| Export produces empty/corrupt file, or the diagram looks blank | Invalid XML, or missing root cells id="0" and id="1" | Run the repair pass and check the basic structure |
GPU process isn't usable. Goodbye. during convert/layout/export | Electron cannot start a GPU process — typical on Windows remote-desktop sessions, VMs, and CI runners. The os_crypt / Failed to decrypt lines printed before it are unrelated noise | Retry the same command with --disable-gpu added; draw.io Desktop's own --disable-acceleration switch has the same effect |
Browser opens with an empty diagram in url mode | cmd.exe stripped the #R... fragment | Use the .url file workaround on Windows/WSL2 (see Opening the URL) — never pass the URL directly to cmd.exe /c start |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
diagram-generation, drawio, mermaid, flowchart, architecture-diagram
npx claudepluginhub jgraph/drawio-mcp --plugin drawioOther plugins' skills for the same job