Style reference for AI diagram generation
This document is a companion to mxfile.xsd and provides all information needed to programmatically generate valid draw.io (.drawio) files. All data was extracted from the draw.io source code.
See also: Generate and validate draw.io diagrams with AI and the .drawio file format
1. File Structure Overview
A minimal valid draw.io file:
<mxfile>
<diagram id="page-1" name="Page-1">
<mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="850" pageHeight="1100"
math="0" shadow="0">
<root>
<!-- Root container (always required, always id="0") -->
<mxCell id="0" />
<!-- Default layer (always required, always id="1", parent="0") -->
<mxCell id="1" parent="0" />
<!-- Diagram elements go here with parent="1" -->
</root>
</mxGraphModel>
</diagram>
</mxfile>
Critical Rules
- The first two mxCell elements are mandatory structural cells:
id="0"— root container, no parent attributeid="1"withparent="0"— default layer
- All diagram elements must have
parent="1"or the id of a group/layer. - IDs must be unique within the diagram. Use any string (e.g. "2", "node-1", "abc123").
- Vertices need
vertex="1"and edges neededge="1". These are mutually exclusive. - Edges should reference source and target via cell IDs. Edges without connections need explicit mxPoint sourcePoint/targetPoint.
- Always use uncompressed XML (no
compressed="true"). AI should not generate compressed content. - Style strings end with semicolon, for example:
"rounded=1;whiteSpace=wrap;html=1;" - Coordinates: origin (0,0) is top-left, x increases rightward, y increases downward.
2. Style String Format
The style attribute on mxCell is a semicolon-separated list of key=value pairs:
key1=value1;key2=value2;key3=value3;
A style class name or shape name can appear as a bare token (without =):
ellipse;whiteSpace=wrap;html=1;fillColor=#DAE8FC;
Here ellipse sets the shape. Multiple bare tokens are possible for style class inheritance:
text;html=1;align=left;
Rules
- Keys and values are case-sensitive
- No spaces around
=or; - Boolean values use
0and1(not true/false) - Colors use
#RRGGBBhex format (with#),none, ordefault - The trailing
;is conventional but not strictly required - Unknown keys are silently ignored
3. Shape Types
3.1 Core mxGraph Shapes
These shapes are defined in the mxGraph core library:
| shape= value | Description | Notes |
|---|---|---|
rectangle | Rectangle (default) | Also the default if no shape specified |
ellipse | Oval / ellipse | Use aspect=fixed for circle |
rhombus | Diamond | Use perimeter=rhombusPerimeter |
triangle | Triangle | Use perimeter=trianglePerimeter |
hexagon | Hexagon | Use perimeter=hexagonPerimeter2 |
cloud | Cloud | Use perimeter=cloudPerimeter |
cylinder | 3D Cylinder | |
line | Horizontal line | |
arrow | Block arrow | |
arrowConnector | Arrow-shaped connector | |
doubleEllipse | Double-bordered ellipse | |
image | Image container | Requires image=<url> |
label | Rectangle with icon area | Default vertex shape |
swimlane | Container with header bar | Use startSize for header height |
actor | Actor (stick figure outline) | |
connector | Edge connector | Default edge shape |
3.2 Extended Shapes (draw.io Shapes.js)
These are registered via mxCellRenderer.registerShape():
| shape= value | Description |
|---|---|
cube | 3D cube |
isoCube | Isometric cube |
isoCube2 | Isometric cube (variant 2) |
isoRectangle | Isometric rectangle |
cylinder2 | Cylinder (variant 2, configurable) |
cylinder3 | Cylinder (variant 3) |
datastore | Cylindrical data store |
note | Sticky note |
note2 | Note (variant 2) |
document | Document page with curled bottom |
folder | Folder icon |
card | Card with cut corner |
tape | Punched tape |
tapeData | Tape data storage |
process | Process box (double-sided borders) |
process2 | Same as process |
step | Step/chevron arrow |
plus | Plus sign |
ext | Extended rectangle (supports double=1) |
callout | Speech bubble |
parallelogram | Parallelogram (use perimeter=parallelogramPerimeter) |
trapezoid | Trapezoid (use perimeter=trapezoidPerimeter) |
curlyBracket | Curly bracket |
switch | Networking switch shape |
transparent | Invisible shape |
message | Envelope/message |
corner | L-shaped corner |
crossbar | Cross bar |
tee | T-shaped connector |
singleArrow | Single arrow |
doubleArrow | Double-headed arrow |
flexArrow | Flexible arrow |
wire | Wire connector |
waypoint | Waypoint marker |
manualInput | Manual input (flowchart) |
internalStorage | Internal storage (flowchart) |
dataStorage | Data storage (flowchart) |
loopLimit | Loop limit (flowchart) |
offPageConnector | Off-page connector |
delay | Delay shape |
display | Display device |
or | OR gate |
orEllipse | OR ellipse |
xor | XOR gate |
sumEllipse | Sum/sigma ellipse |
sortShape | Sort shape |
collate | Collate shape |
cross | Cross / X shape |
dimension | Dimension line |
partialRectangle | Rectangle with configurable borders |
lineEllipse | Line with ellipse |
link | Link / chain shape |
pipe | Pipe connector |
zigzag | Zigzag connector |
filledEdge | Filled edge connector |
taperedArrow | Connector that tapers from startWidth (default 12) to endWidth (default 2). Supports rounded and curved, and fillColor / gradientColor like flexArrow (no fill by default). startSize / endSize is how much wider the arrow head is than the band at that end. |
table | Table container. evenRowColor / oddRowColor and evenColumnColor / oddColumnColor add alternating stripes to rows and columns |
tableRow | Table row |
tableLine | Table line |
rect2 | Alternative rectangle |
tie | Tie that bundles edges (with tie=1, see §4.4): a line across the lanes of its edges with a head at one end, drawn with strokeColor, strokeWidth and dashed. New ties use shape=tie;tie=1;resizable=0;rotatable=0;connectable=0;fillColor=none;strokeWidth=3; |
3.3 UML Shapes
| shape= value | Description |
|---|---|
umlActor | UML stick figure |
umlBoundary | UML boundary |
umlEntity | UML entity |
umlDestroy | UML destruction mark |
umlControl | UML control |
umlLifeline | UML lifeline |
umlFrame | UML frame |
umlState | UML state (use perimeter=mxPerimeter.StatePerimeter) |
lollipop | UML provided interface |
requires | UML required interface |
requiredInterface | UML required interface (arc) |
providedRequiredInterface | UML assembly connector |
module | UML module |
component | UML component |
associativeEntity | ER associative entity |
endState | State diagram end state |
startState | State diagram start state |
3.4 Stencil Libraries
Additional shapes are available via stencil libraries in the stencils/ directory.
Use with: shape=stencil(<library>.<shape>) or shape=mxgraph.<library>.<shape>.
Major libraries:
mxgraph.flowchart.*— Flowchart shapesmxgraph.bpmn.*— BPMN shapesmxgraph.aws4.*— AWS architecture iconsmxgraph.azure.*— Azure architecture iconsmxgraph.gcp.*/mxgraph.gcp2.*— Google Cloud iconsmxgraph.cisco.*/mxgraph.cisco19.*— Cisco networkingmxgraph.kubernetes.*— Kubernetes iconsmxgraph.uml.*— UML shapesmxgraph.er.*— Entity-relationship shapesmxgraph.electrical.*— Electrical engineering symbolsmxgraph.pid.*— Piping and instrumentationmxgraph.mockup.*— UI wireframe componentsmxgraph.lean_mapping.*— Lean mappingmxgraph.eip.*— Enterprise integration patterns
4. Style Properties Reference
4.1 Fill and Stroke
| Property | Values | Default | Description |
|---|---|---|---|
fillColor | #RRGGBB, none, default, keyword | default | Shape fill color |
gradientColor | #RRGGBB, none, keyword | none | Gradient end color (gradient from fillColor to gradientColor) |
gradientDirection | north, south, east, west | south | Gradient direction |
strokeColor | #RRGGBB, none, default, keyword | default | Border/stroke color |
strokeWidth | number | 1 | Border width in pixels |
dashed | 0, 1 | 0 | Dashed stroke |
dashPattern | string | — | Dash pattern, e.g. "1 3" (1px dash, 3px gap), "8 8" |
opacity | 0–100 | 100 | Overall opacity (0=transparent, 100=opaque) |
fillOpacity | 0–100 | 100 | Fill opacity only |
strokeOpacity | 0–100 | 100 | Stroke opacity only |
glass | 0, 1 | 0 | Glass/shine overlay effect |
shadow | 0, 1 | 0 | Drop shadow (also controlled globally on mxGraphModel) |
multiple | 0, 1 | 0 | Paints copies of a vertex stacked behind it, for example to show several instances. Connectors end on the outline of the stack instead of crossing the copies. The label and the selection stay on the front shape. Ignored on edges |
multipleCount | 1–10 | 2 | With multiple=1: number of copies behind the shape |
multipleDx | number | 8 | With multiple=1: horizontal offset of each copy from the one in front of it, in pixels on the page (also for rotated and flipped shapes) |
multipleDy | number | -8 | With multiple=1: vertical offset of each copy from the one in front of it, in pixels on the page (negative values go up) |
opacityGroup | 0, 1 | 0 | Applies opacity to the shape as a whole, so that overlapping parts (the line under a filled arrow head, the stroke over the fill) do not get darker. Set together with the opacity in the Style tab |
4.2 Shape Geometry
| Property | Values | Default | Description |
|---|---|---|---|
shape | see Shape Types above | label | Shape type |
perimeter | see Perimeters below | rectanglePerimeter | Connection point calculation |
rounded | 0, 1 | 0 | Round the corners of rectangles, polygons (e.g. rhombus, triangle, hexagon) and shapes with curved sides (document, tape, dataStorage, or, xor). On curved sides the rounding follows the tangent of the curve |
arcSize | number | — | Corner size for rounded shapes. Rectangle-based shapes (e.g. rectangle, label, process): the radius is arcSize percent of the shorter side (0–50, default 15), or arcSize / 2 pixels with absoluteArcSize=1. Other shapes (polygons, document, tape, dataStorage, or, xor): the radius is arcSize / 2 pixels (default 20), at most half of each side |
aspect | variable, fixed | variable | fixed preserves width/height ratio |
direction | north, south, east, west | — | Rotate shape by 90° increments |
flipH | 0, 1 | 0 | Flip horizontally |
flipV | 0, 1 | 0 | Flip vertically |
rotation | number (degrees) | 0 | Free rotation angle (0–360) |
fixedSize | 0, 1 | 0 | Shape keeps size independent of label |
roundedPerimeter | 0, 1 | 0 | With rounded=1 on rectangles and labels, perimeter connection points and floating edges end on the rounded outline instead of the bounding box. Corner connection points sit at 45° on the arc. Other shapes: see below |
roundedPerimeter also applies to process and internalStorage, and to triangle, rhombus, hexagon, parallelogram, trapezoid and step with their default perimeter, where connectors end on the rounded corners as painted. Other shapes ignore it. The Rounded sets the key on all of these shapes when applied.
4.3 Text and Labels
| Property | Values | Default | Description |
|---|---|---|---|
html | 0, 1 | 1 | Enable HTML label rendering |
whiteSpace | wrap, nowrap | — | Text wrapping mode. Use wrap for most shapes |
fontSize | number | 12 | Font size in pixels |
fontFamily | string | Helvetica | Font family name |
fontColor | #RRGGBB, default, keyword | default | Text color |
fontStyle | bitmask | 0 | Font style: 0=normal, 1=bold, 2=italic, 4=underline (combine by adding: 3=bold+italic) |
align | left, center, right | center | Horizontal text alignment |
verticalAlign | top, middle, bottom | middle | Vertical text alignment |
labelPosition | left, center, right | center | Horizontal label position relative to shape |
verticalLabelPosition | top, middle, bottom | middle | Vertical label position relative to shape |
labelPerimeter | 0, 1 | 0 | On a shape whose label is outside its outline, centred on one side (verticalLabelPosition=top or bottom with labelPosition=center, or labelPosition=left or right with verticalLabelPosition=middle), connectors that would cross the label end at its outline instead (plus the perimeter spacing), and a fixed connection point on that side moves to the far edge of the label. Ignored on rotated and flipped shapes. Automatically set on library shapes with an outside label, and when the Position in the Text tab is changed to an outside position. |
overflow | visible, hidden, fill, width | — | Text overflow handling |
spacing | number | 2 | General padding in pixels |
spacingTop | number | 0 | Top padding |
spacingBottom | number | 0 | Bottom padding |
spacingLeft | number | 0 | Left padding |
spacingRight | number | 0 | Right padding |
textOpacity | 0–100 | 100 | Text opacity |
labelPlacement | auto | — | On a connector or a connector label: the label stays horizontal and sits just above horizontal segments, or below when something is in the way, and on the line (with a label gap) on vertical and diagonal segments. It avoids bends and arrowheads, and a label that doesn't fit its segment moves to the nearest longer segment. Placed again when the route changes. A label with an offset maintains that offset and only moves to the side appropriate for its segment. Not applied to vertical text (horizontal=0) |
labelBackgroundColor | #RRGGBB, none, default | — | Background behind text (useful for edge labels). Shown as None (none) or Solid (a colour) in the Background list of the Text tab |
defaultLabelBackgroundColor | page | — | With labelBackgroundColor=default: no background, the label box is cut out of the shape and of the parent edge, so the page and the cells behind the label stay visible. gap has the same effect. The default edge style sets it, so new edges and edge labels use it. Shown as Transparent in the Background list of the Text tab, which offers it for edges and their label cells |
inheritText | 1, comma-separated keys | — | On a label cell of an edge: the text styles that the label takes from the edge, 1 for all of fontFamily (with fontSource), fontSize, fontColor, fontStyle, textOpacity, labelBorderColor, labelBorderWidth, labelBackgroundColor, defaultLabelBackgroundColor and labelPadding. The label also stores the values of the edge in these keys for applications that don't support inheritText. Setting one of these keys on the label removes it from the list. The value inherit of one of these keys also takes it from the edge. New double-click labels and the label cells of the edge templates use inheritText=1; Use Connector Style in the Text tab sets it again |
labelBorderColor | #RRGGBB, none | — | Border around label |
labelWidth | number | — | Fixed label width |
textDirection | default, ltr, rtl | default | Text direction |
horizontal | 0, 1 | 1 | 0 for vertical text. For swimlanes and table rows, it also sets the side of the title region; combine horizontal=1;direction=north for a title on the left with horizontal text |
4.4 Edge / Connector Properties
| Property | Values | Default | Description |
|---|---|---|---|
edgeStyle | see Edge Styles below | — | Routing algorithm |
ties | comma-separated cell IDs | — | IDs of the tie vertices (tie=1) the edge runs through, in order from source to target. The bundled edge passes each tie in its own lane and is routed between its terminals and the ties with its edgeStyle (edges without an edgeStyle get a short straight piece along each tie). Waypoints and libavoidRouting are ignored while the edge has ties. IDs of missing or hidden cells are ignored. The edge stays one edge (source, target, labels and arrows are unchanged) |
tie | 0, 1 | 0 | On a vertex: the vertex is a tie that the edges listing its ID in ties run through. Its center is where its edges cross it and its size follows the number of lanes. It points in the direction most of its edges travel, or along an axis if all of them are orthogonal |
tieSpacing | number | 6 | On a tie: distance between the lanes of its edges |
libavoidRouting | 0, 1 | 0 | Auto-route the edge around shapes (obstacle-avoiding orthogonal routing, paired with edgeStyle=orthogonalEdgeStyle). Re-routed when a terminal or a shape on the route changes; a manual waypoint edit removes it |
curved | 0, 1 | 0 | Curved edge path |
curveGeometry | 0, 1 | 0 | With curved=1 or bezier=1: labels and line jumps follow the painted curve instead of the control points. Added to new curved edges |
labelOnCurve | 0, 1 | 0 | With curved=1 or bezier=1, edge labels are placed along the painted curve instead of the line through the waypoints (x and y of the label geometry are measured along the curve). The editor sets and removes it together with curved and adds it to new curved edges. |
trimCurve | 0, 1 | 0 | With curved=1 or bezier=1: the curve is painted as without markers and cut where the start and end markers begin, so markers don't change its course. Line jumps follow the cut curve. Trim Curve in the Property section |
rounded | 0, 1 | 1 | Round edge corners (for orthogonal) |
jettySize | auto, number | auto | Spacing from port for orthogonal edges |
sourceJettySize | number | — | Source-side jetty override |
targetJettySize | number | — | Target-side jetty override |
orthogonalLoop | 0, 1 | 1 | Self-loop routing style |
elbow | horizontal, vertical | — | Elbow edge direction |
jumpStyle | arc, gap, sharp, line | — | Line crossing visualization (curved edges need curveGeometry=1) |
jumpSize | number | 6 | Jump width at crossings |
jumpLayers | 0, 1 | 1 | 0 only adds jumps for crossings with edges in the same layer as this edge |
followTerminals | 0, 1 | 0 | Waypoints move with the terminals when these are moved, resized or arranged: orthogonal edges keep axis-parallel segments, other edges keep each waypoint's relative position along and distance from the line between the terminal centres. No effect with libavoidRouting=1 |
| Property | Values | Default | Description |
|---|---|---|---|
libavoidSpacing | number | 16 | With libavoidRouting=1: distance between the edge and the shapes it routes around (Spacing in the Line section of the Style tab) |
4.5 Arrow Markers
| Property | Values | Default | Description |
|---|---|---|---|
startArrow | arrow type | none | Marker at edge start |
endArrow | arrow type | classic | Marker at edge end |
startSize | number | — | Start marker size |
endSize | number | — | End marker size |
startFill | 0, 1 | 1 | Fill start marker |
endFill | 0, 1 | 1 | Fill end marker |
startFillColor | #RRGGBB | — | Fill colour of the start marker (default: line colour) |
endFillColor | #RRGGBB | — | Fill colour of the end marker (default: line colour) |
startStrokeColor | #RRGGBB | — | Outline colour of the start marker (default: line colour) |
endStrokeColor | #RRGGBB | — | Outline colour of the end marker (default: line colour) |
Arrow type values:
| Value | Description |
|---|---|
none | No arrow |
classic | Standard filled triangle |
classicThin | Thin triangle |
block | Filled block |
blockThin | Thin block |
open | Open (unfilled) triangle |
openThin | Thin open triangle |
oval | Circle/oval |
diamond | Diamond |
diamondThin | Thin diamond |
box | Square box |
halfCircle | Half circle |
circle | Circle |
circlePlus | Circle with plus |
cross | Cross mark |
baseDash | Perpendicular dash |
doubleBlock | Double filled block |
dash | Short dash |
async | Asynchronous (half-arrow) |
openAsync | Open asynchronous arrow |
manyOptional | ER many-optional (crow's foot) |
Fill behavior: startFill=0/endFill=0 renders the marker as an outline only. This is important for UML and ER diagram conventions (e.g., open diamond = aggregation, filled diamond = composition).
4.6 Connection Points
| Property | Values | Default | Description |
|---|---|---|---|
exitX | 0.0–1.0 | — | Relative x of exit point (0=left, 0.5=center, 1=right) |
exitY | 0.0–1.0 | — | Relative y of exit point (0=top, 0.5=middle, 1=bottom) |
exitDx | number | — | Absolute x offset from exit point |
exitDy | number | — | Absolute y offset from exit point |
exitPerimeter | 0, 1 | 1 | Use perimeter for exit point |
entryX | 0.0–1.0 | — | Relative x of entry point |
entryY | 0.0–1.0 | — | Relative y of entry point |
entryDx | number | — | Absolute x offset from entry point |
entryDy | number | — | Absolute y offset from entry point |
entryPerimeter | 0, 1 | 1 | Use perimeter for entry point |
portConstraint | eastwest, northsouth, perimeter, fixed | — | Port constraint |
sourcePerimeterSpacing | number | 0 | Gap between the edge start and the source shape (Line start offset) |
targetPerimeterSpacing | number | 0 | Gap between the edge end and the target shape (Line end offset) |
fixedPointSpacing | 0, 1 | 0 | Also apply sourcePerimeterSpacing / targetPerimeterSpacing to ends attached to a fixed connection point. Negative values extend the end outward. Set automatically when Line start/end offset is edited in the Format panel |
4.7 Container / Swimlane Properties
| Property | Values | Default | Description |
|---|---|---|---|
container | 0, 1 | 0 | Cell is a container (children can be placed inside) |
collapsible | 0, 1 | 1 | Container can be collapsed |
recursiveResize | 0, 1 | 1 | Resize children when container resizes |
swimlaneFillColor | #RRGGBB | — | Swimlane header fill color |
startSize | number | 23 | Swimlane header height in pixels |
horizontal | 0, 1 | 1 | Swimlane orientation (1=header on top, 0=header on left) |
childLayout | stackLayout, tableLayout, rack, circleLayout, flowLayout, treeLayout, organicLayout, URL-encoded JSON | — | Layout that arranges the children (see below) |
childLayout values: The layout runs when the container or its children change, not when the diagram is opened.
| Value | Layout |
|---|---|
stackLayout | Stacks the children in a row or column and stretches them across the container, e.g. lists and UML class members |
tableLayout | Rows and cells of a shape=table table |
rack | Rack cabinet: stacks the devices from top to bottom |
circleLayout | Places the children on a circle |
flowLayout | Layered flow, runs as the ELK layout elkLayered |
treeLayout | Tree, runs as the ELK layout elkTree; connectors retain their style |
organicLayout | Force-directed, runs as the ELK layout elkOrganic |
| URL-encoded JSON | A layout list as in the JSON layout specification, URL-encoded so that no ; or = breaks the style string, e.g. childLayout=%5B%7B%22layout%22%3A%22elkTree%22%7D%5D for [{"layout":"elkTree"}] |
flowLayout, treeLayout and organicLayout run as ELK layouts, and their style keys below are translated to ELK options (See the JSON layout specification).
Layout style keys:
| Property | Values | Default | Description |
|---|---|---|---|
resizeParent | 0, 1 | 1 | The container resizes to fit its children (stackLayout, circleLayout, flowLayout, treeLayout, organicLayout) |
resizeParentMax | 0, 1 | 1 | stackLayout: the container only grows, it never shrinks |
resizeLast | 0, 1 | 0 | stackLayout: the last child fills the remaining space |
horizontalStack | 0, 1 | 1 | stackLayout: 1 places the children side by side, 0 stacks them top to bottom |
stackSpacing | number | 0 | stackLayout: gap between the children |
stackBorder | number | 0 | stackLayout: gap between the container and its children |
marginTop, marginRight, marginBottom, marginLeft | number | 0 | stackLayout, rack: additional space inside the container |
allowGaps | 1 | — | stackLayout, rack: retain the gaps between the children, in steps of stackUnitSize or rackUnitSize. Omit for no gaps (any value, including 0, will enable gaps) |
stackUnitSize | number | 20 | stackLayout with allowGaps: step size of the gaps |
rackUnitSize | number | 20 | rack: height of one rack unit |
horizontalRack | 0, 1 | 0 | rack: 1 places the devices side by side |
flowOrientation | north, west, east, south | east | flowLayout: side of the roots — north top to bottom, west left to right, east right to left, south bottom to top |
intraCellSpacing | number | 30 | flowLayout: gap between shapes in the same rank |
interRankCellSpacing | number | 100 | flowLayout: gap between ranks |
interHierarchySpacing | number | 60 | flowLayout: gap between unconnected parts |
parallelEdgeSpacing | number | 10 | flowLayout: gap between parallel connectors |
horizontalTree | 0, 1 | 1 | treeLayout: 1 left to right, 0 top to bottom |
treeLevelDistance | number | 30 | treeLayout: gap between levels and between siblings (minimum 20) |
parentPadding | number | 20 | flowLayout, treeLayout, organicLayout: gap between the container border (below its title) and its children |
4.8 Image Properties
| Property | Values | Default | Description |
|---|---|---|---|
image | URL string | — | Image URL (data: URIs also supported) |
imageWidth | number | 42 | Image width |
imageHeight | number | 42 | Image height |
imageAlign | left, center, right | — | Image horizontal alignment |
imageVerticalAlign | top, middle, bottom | — | Image vertical alignment |
imageAspect | 0, 1 | 1 | Preserve image aspect ratio |
4.9 Sketch / Hand-Drawn Style
| Property | Values | Default | Description |
|---|---|---|---|
sketch | 0, 1 | 0 | Enable hand-drawn/sketch style (uses rough.js) |
comic | 0, 1 | 0 | Comic book style |
fillStyle | solid, hachure, cross-hatch, dots | — | Fill pattern for sketch mode |
fillWeight | number | — | Hatch line weight (negative = thinner) |
hachureGap | number | — | Gap between hatch lines in pixels |
hachureAngle | number (degrees) | — | Angle of hatch lines |
jiggle | number | — | Hand-drawn jiggle amount |
curveFitting | 0–1 | — | Curve fitting quality |
simplification | 0–1 | — | Path simplification |
disableMultiStroke | 0, 1 | — | Disable double-stroke effect |
disableMultiStrokeFill | 0, 1 | — | Disable double-stroke fill |
4.10 Behavior Properties
| Property | Values | Default | Description |
|---|---|---|---|
movable | 0, 1 | 1 | Allow moving |
resizable | 0, 1 | 1 | Allow resizing |
rotatable | 0, 1 | 1 | Allow rotation |
bendable | 0, 1 | 1 | Allow bending edges |
collapsedPoints | 0, 1 | 1 | 0 ignores the edge's waypoints while one of its ends is hidden in a collapsed container (the stored waypoints are kept and used again when expanded; the edge can't be bent in that state) |
editable | 0, 1 | 1 | Allow label editing |
deletable | 0, 1 | 1 | Allow deletion |
cloneable | 0, 1 | 1 | Allow cloning |
foldable | 0, 1 | — | Allow fold/collapse |
connectable | 0, 1 | 1 | Allow connections |
newEdgeStyle | URL-encoded JSON style | — | Style of new connectors drawn from this shape. Set it with Use for New Connections from Source (formerly Set New Connection Default) on a connector from this shape, and remove it with Clear Style for New Connections (formerly Clear New Connection Default) on the shape |
pointerEvents | 0, 1 | 1 | Enable mouse events |
autosize | 0, 1 | 0 | Auto-size to fit content |
4.11 Data Properties
Values in the style of a cell can come from its data, and from the style rules of the page.
| Property | Values | Default | Description |
|---|---|---|---|
stylePlaceholders | 0, 1 | 0 | 1 replaces placeholders such as %color% in the values of the keys in the table below with the data of the cell, its ancestors and the page, like placeholders in labels. Each value is checked for its key: keys whose value is not valid after the placeholders are replaced are removed, numbers are limited to the range of the key. Placeholders in other keys are not replaced. The CSV import keeps these placeholders in styles with stylePlaceholders=1, so the styles follow later changes of the data. Example: fillColor=%color%;stylePlaceholders=1; |
styleRules | 0, 1 | 1 | 0: the style rules of the page don't change the cell, for example the shapes of a legend that Insert Legend adds |
Keys that placeholders and style rules can set:
| Keys | Values |
|---|---|
fillColor, gradientColor, strokeColor, fontColor, labelBackgroundColor, labelBorderColor, swimlaneFillColor | #hex, rgb(), rgba(), hsl() or hsla() with numbers, a colour name, light-dark() of two colours, none or default |
opacity, fillOpacity, strokeOpacity, textOpacity | 0 to 100 |
strokeWidth | 0 to 100 |
fontSize | 1 to 500 |
fontStyle | 0 to 15, rounded |
rotation | -360 to 360 |
dashed, rounded, shadow | 0, 1 |
image | https:// URL without quotes, spaces, ; or parentheses, up to 2048 characters. An image without placeholders, for example a data: URI that contains %, is kept as it is |
5. Edge Styles (Routing Algorithms)
| edgeStyle= value | Description |
|---|---|
orthogonalEdgeStyle | Routes with right-angle turns (most common) |
segmentEdgeStyle | Manual segments with horizontal/vertical segments |
elbowEdgeStyle | Single elbow (one bend). Combine with elbow=horizontal or elbow=vertical |
entityRelationEdgeStyle | Entity-relationship style (perpendicular exits) |
isometricEdgeStyle | Isometric diagram routing |
loopEdgeStyle | Self-referencing loop |
sideToSideEdgeStyle | Side-to-side connection |
topToBottomEdgeStyle | Top-to-bottom connection |
| (empty/none) | Straight line, no routing |
Common edge style combinations:
edgeStyle=orthogonalEdgeStyle;rounded=1; # Rounded orthogonal (default-like)
edgeStyle=orthogonalEdgeStyle;curved=1; # Curved orthogonal
edgeStyle=elbowEdgeStyle;elbow=horizontal; # Horizontal elbow
edgeStyle=entityRelationEdgeStyle; # ER-style connections
edgeStyle=none; # Straight line
6. Perimeter Types
The perimeter determines how connection points are calculated on a shape's border:
| perimeter= value | Use with |
|---|---|
rectanglePerimeter | Rectangles (default) |
ellipsePerimeter | Ellipses, circles |
rhombusPerimeter | Diamond shapes |
trianglePerimeter | Triangles |
hexagonPerimeter2 | Hexagons |
parallelogramPerimeter | Parallelograms |
trapezoidPerimeter | Trapezoids |
calloutPerimeter | Callout/speech bubbles |
backbonePerimeter | Backbone/bus shapes |
centerPerimeter | Single center point |
stepPerimeter | Step/chevron shapes |
cloudPerimeter | Clouds: connectors end on the outline of the cloud as drawn (without it, ellipse;shape=cloud uses the ellipse) |
Important: When using non-rectangular shapes, always set the matching perimeter. Otherwise edges will connect to the rectangular bounding box instead of the visible shape border.
7. Predefined Style Classes
These class names can be used as bare tokens in the style string. They set multiple style properties at once:
| Class | Sets |
|---|---|
text | No fill, no stroke, left-aligned, top-aligned |
edgeLabel | Extends text, adds label background, font size 11 |
label | Bold, left-aligned, with image area (42x42), rounded |
icon | Extends label, centered image above text |
swimlane | Swimlane shape, bold, header size 23 |
group | No fill, no stroke, transparent container |
ellipse | Ellipse shape with ellipsePerimeter |
rhombus | Diamond shape with rhombusPerimeter |
triangle | Triangle shape with trianglePerimeter |
line | Line shape, strokeWidth=4 |
image | Image shape with label below |
arrow | Arrow shape, no edge routing |
Color Theme Classes
Each sets fillColor, gradientColor, strokeColor, plus shadow=1 and glass=1:
| Class | fillColor | gradientColor | strokeColor |
|---|---|---|---|
blue | #DAE8FC | #7EA6E0 | #6C8EBF |
green | #D5E8D4 | #97D077 | #82B366 |
yellow | #FFF2CC | #FFD966 | #D6B656 |
orange | #FFCD28 | #FFA500 | #D79B00 |
red | #F8CECC | #EA6B66 | #B85450 |
pink | #E6D0DE | #B5739D | #996185 |
purple | #E1D5E7 | #8C6C9C | #9673A6 |
gray | #F5F5F5 | #B3B3B3 | #666666 |
turquoise | #D5E8D4 | #67AB9F | #6A9153 |
plain-* variants (e.g. plain-blue) set the same colors without shadow and glass.
8. Common Color Palettes
Standard draw.io Colors
These are commonly used in the draw.io UI:
Fill colors (light):
#DAE8FC(light blue)#D5E8D4(light green)#FFF2CC(light yellow)#F8CECC(light red)#E1D5E7(light purple)#E6D0DE(light pink)#F5F5F5(light gray)#FFCD28(orange)#FFE6CC(light orange)
Stroke colors (matching):
#6C8EBF(blue)#82B366(green)#D6B656(yellow/gold)#B85450(red)#9673A6(purple)#996185(pink)#666666(gray)#D79B00(orange)
Font/accent colors:
#000000(black)#FFFFFF(white)#333333(dark gray)#0000EE(link blue)
Special Color Values
none— transparent / no color (removes fill or stroke)default— uses the current theme's default (resolves at render time)
The following keywords refer to another colour. They can be used as the value
of fillColor, strokeColor, gradientColor and fontColor:
inherit— the same colour of the parent cell, e.g.fillColor=inherituses the fill colour of the containerfillColor,strokeColor— the fill or stroke colour of the cell itself, e.g.fillColor=strokeColorfills the shape with its stroke colourparentFillColor,parentStrokeColor— the fill or stroke colour of the parent cell, e.g.strokeColor=parentFillColordraws the border in the fill colour of the container
Cells on a layer have no parent shape, so inherit, parentFillColor and
parentStrokeColor use the default colour there.
9. HTML Labels
When html=1 is set in the style, the cell's value attribute can contain HTML:
Supported HTML Elements
<b>,<i>,<u>,<s>— text formatting<br>/<br/>— line break<p>,<div>,<span>— block/inline containers<font>— font attributes (face, size, color)<table>,<tr>,<td>,<th>— tables<ul>,<ol>,<li>— lists<hr>— horizontal rule<img>— inline images (with src attribute)<a>— links (href attribute)<sub>,<sup>— subscript/superscript
HTML in Attributes
HTML in the value attribute must be XML-escaped:
<→<>→>&→&"→"
Example:
<mxCell value="<b>Title</b><br>Description"
style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
Common HTML Patterns
Bold title with description:
<b>Title</b><br>Description text
UML class box (within table container):
<p style="margin:0px;margin-top:4px;text-align:center;"><b>ClassName</b></p>
<hr size="1"/>
<p style="margin:0px;margin-left:4px;">+ field: Type</p>
<hr size="1"/>
<p style="margin:0px;margin-left:4px;">+ method(): ReturnType</p>
Colored text:
<font color="#FF0000">Red text</font>
10. Layers
Layers are additional mxCell elements with parent="0":
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" /> <!-- Default layer -->
<mxCell id="layer2" value="Background" parent="0" /> <!-- Additional layer -->
<!-- Elements on default layer -->
<mxCell id="2" ... parent="1" />
<!-- Elements on "Background" layer -->
<mxCell id="3" ... parent="layer2" />
</root>
To hide a layer: add visible="0" to the layer cell.
11. Groups and Containers
A group/container is a vertex that other cells reference as their parent:
<!-- Group container -->
<mxCell id="group1" value="Group" style="group;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="300" height="200" as="geometry" />
</mxCell>
<!-- Children reference the group as parent -->
<mxCell id="child1" value="Inside" style="rounded=1;html=1;" vertex="1" parent="group1">
<mxGeometry x="10" y="10" width="100" height="40" as="geometry" />
</mxCell>
Key points:
- Child coordinates are relative to the parent container
- Use
style="group;"for invisible containers - Use
style="swimlane;startSize=30;"for containers with a visible header - Add
container=1;to any style to make it act as a container collapsible=0;prevents the collapse/expand button
Collapsible Containers and Alternate Bounds
When a container (e.g. swimlane) is collapsible, draw.io stores alternate bounds
in an mxRectangle child element inside mxGeometry. When the container is
collapsed/expanded, the geometry swaps between the normal and alternate bounds:
<mxCell id="class1" value="ClassName" style="swimlane;fontStyle=1;childLayout=stackLayout;startSize=26;collapsible=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="200" height="150" as="geometry">
<mxRectangle x="100" y="100" width="200" height="26" as="alternateBounds" />
</mxGeometry>
</mxCell>
The alternateBounds typically has the same x/y but a smaller height (just the header).
AI generators generally do not need to produce mxRectangle elements — draw.io adds
them automatically when the user collapses a container.
12. Pages, Links, Tags and Page Data
These features are stored as attributes, not in the style. The .drawio file format reference describes them in §2.2 and §2.8–§2.11.
Multiple Pages
Each page is one <diagram> element inside <mxfile>, with its own <mxGraphModel>:
<mxfile pages="2">
<diagram id="overview" name="Overview">
<mxGraphModel>...</mxGraphModel>
</diagram>
<diagram id="details" name="Details">
<mxGraphModel>...</mxGraphModel>
</diagram>
</mxfile>
Key points:
- Every page needs its own structural cells
id="0"andid="1" - Page
idvalues must be unique in the file. Cell IDs only need to be unique within a page - The page tabs follow the order of the
<diagram>elements - Links and background pages refer to the page
id, not to itsname
Links
A link is the link attribute of a UserObject (or object) wrapper:
<UserObject id="2" label="Details" link="data:page/id,details">
<mxCell style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="120" height="60" as="geometry" />
</mxCell>
</UserObject>
link value | Effect |
|---|---|
https://… | Opens the URL. Add linkTarget="_blank" to open it in a new window |
data:page/id,PAGE_ID | Opens the page with this id in the same file |
data:action/json,{"actions":[…]} | Runs custom actions, such as {"toggle":{"cells":["3"]}}. See the JSON actions reference. Escape " as " in the attribute |
Tags
tags on the wrapper holds the tags of a cell, separated by spaces, for example tags="backend critical". Tags are case-sensitive and can't contain spaces. In the Tags dialog, readers can hide tags: a cell is hidden when all of its tags are hidden. Which tags are hidden is not stored in the file.
Page Data and Page Animations
Attributes of the whole page go on a UserObject that wraps the root cell id="0". The mxCell inside has no id and no parent:
<UserObject id="0" label="" owner="ITS" animation="{"animation":{"steps":[{"fadeOut":{"cells":["*"]}},{"fadeIn":{"cells":["2"]}}]}}">
<mxCell />
</UserObject>
<mxCell id="1" parent="0" />
- Custom attributes such as
ownerare page data. The placeholder%owner%in a label withplaceholders="1"shows the value animationis the page animation. It plays in the lightbox viewer and in presentation mode.stepstakes the same actions asdata:action/json,linksstyleRulesanddataSourceshold the style rules and data sources of the page as JSON arrays. AI generators typically do not need to write them
13. Edge Geometry and Labels
Basic Connected Edge
<mxCell id="e1" value="" style="endArrow=classic;html=1;"
edge="1" parent="1" source="v1" target="v2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
Edge with Waypoints
<mxCell id="e2" value="" style="edgeStyle=orthogonalEdgeStyle;html=1;"
edge="1" parent="1" source="v1" target="v2">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="300" y="150" />
<mxPoint x="300" y="250" />
</Array>
</mxGeometry>
</mxCell>
Edge with Label
Edge labels are usually encoded in the edge cell's value. The label position is controlled by the geometry:
<mxCell id="e3" value="label text" style="endArrow=classic;html=1;"
edge="1" parent="1" source="v1" target="v2">
<mxGeometry x="-0.5" y="0" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
xon geometry: position along edge (-1 to 1, where 0 = center, -1 = near source, 1 = near target)yon geometry: perpendicular offset in pixels- With
labelOnCurve=1on a curved edge,xandyare measured along and perpendicular to the painted curve instead of the line through the waypoints
Edge with Label Cells
More labels are vertex children of the edge with a relative geometry, connectable="0" and the edgeLabel style. With inheritText=1 they take the text styles of the edge (see 4.3 Text and Labels):
<mxCell id="l1" value="1" style="edgeLabel;html=1;align=left;verticalAlign=bottom;resizable=0;inheritText=1;"
vertex="1" connectable="0" parent="e3">
<mxGeometry x="-1" relative="1" as="geometry" />
</mxCell>
xon geometry: position along the edge (-1 to 1),y: perpendicular offset,offset: an extra offset in pixels
Unconnected Edge (Floating)
<mxCell id="e4" value="" style="endArrow=classic;html=1;"
edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="100" y="200" as="sourcePoint" />
<mxPoint x="300" y="100" as="targetPoint" />
</mxGeometry>
</mxCell>
14. Complete Examples
Example 1: Simple Flowchart
<mxfile>
<diagram id="flowchart" name="Flowchart">
<mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="850" pageHeight="1100">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Start -->
<mxCell id="start" value="Start" style="ellipse;whiteSpace=wrap;html=1;fillColor=#D5E8D4;strokeColor=#82B366;" vertex="1" parent="1">
<mxGeometry x="340" y="40" width="120" height="60" as="geometry" />
</mxCell>
<!-- Decision -->
<mxCell id="decision" value="Condition?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#FFF2CC;strokeColor=#D6B656;" vertex="1" parent="1">
<mxGeometry x="320" y="150" width="160" height="80" as="geometry" />
</mxCell>
<!-- Process A -->
<mxCell id="procA" value="Process A" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#DAE8FC;strokeColor=#6C8EBF;" vertex="1" parent="1">
<mxGeometry x="160" y="290" width="120" height="60" as="geometry" />
</mxCell>
<!-- Process B -->
<mxCell id="procB" value="Process B" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#DAE8FC;strokeColor=#6C8EBF;" vertex="1" parent="1">
<mxGeometry x="520" y="290" width="120" height="60" as="geometry" />
</mxCell>
<!-- End -->
<mxCell id="end" value="End" style="ellipse;whiteSpace=wrap;html=1;fillColor=#F8CECC;strokeColor=#B85450;" vertex="1" parent="1">
<mxGeometry x="340" y="420" width="120" height="60" as="geometry" />
</mxCell>
<!-- Edges -->
<mxCell id="e1" style="endArrow=classic;html=1;" edge="1" parent="1" source="start" target="decision">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e2" value="Yes" style="endArrow=classic;html=1;" edge="1" parent="1" source="decision" target="procA">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e3" value="No" style="endArrow=classic;html=1;" edge="1" parent="1" source="decision" target="procB">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e4" style="endArrow=classic;html=1;" edge="1" parent="1" source="procA" target="end">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e5" style="endArrow=classic;html=1;" edge="1" parent="1" source="procB" target="end">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Example 2: UML Class Diagram
<mxfile>
<diagram id="uml" name="Classes">
<mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="850" pageHeight="1100">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Class: Animal -->
<mxCell id="animal" value="<p style="margin:0px;margin-top:4px;text-align:center;"><i>&lt;&lt;abstract&gt;&gt;</i><br><b>Animal</b></p><hr size="1"/><p style="margin:0px;margin-left:4px;">+ name: String<br>+ age: int</p><hr size="1"/><p style="margin:0px;margin-left:4px;">+ speak(): void<br>+ move(): void</p>" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="300" y="40" width="200" height="140" as="geometry" />
</mxCell>
<!-- Class: Dog -->
<mxCell id="dog" value="<p style="margin:0px;margin-top:4px;text-align:center;"><b>Dog</b></p><hr size="1"/><p style="margin:0px;margin-left:4px;">+ breed: String</p><hr size="1"/><p style="margin:0px;margin-left:4px;">+ fetch(): void</p>" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="180" y="260" width="160" height="120" as="geometry" />
</mxCell>
<!-- Class: Cat -->
<mxCell id="cat" value="<p style="margin:0px;margin-top:4px;text-align:center;"><b>Cat</b></p><hr size="1"/><p style="margin:0px;margin-left:4px;">+ indoor: boolean</p><hr size="1"/><p style="margin:0px;margin-left:4px;">+ purr(): void</p>" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="460" y="260" width="160" height="120" as="geometry" />
</mxCell>
<!-- Inheritance: Dog extends Animal -->
<mxCell id="e1" style="endArrow=block;endFill=0;html=1;" edge="1" parent="1" source="dog" target="animal">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<!-- Inheritance: Cat extends Animal -->
<mxCell id="e2" style="endArrow=block;endFill=0;html=1;" edge="1" parent="1" source="cat" target="animal">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Example 3: Network Diagram with Groups
<mxfile>
<diagram id="network" name="Network">
<mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="850" pageHeight="1100">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- DMZ Group -->
<mxCell id="dmz" value="DMZ" style="swimlane;startSize=25;fillColor=#F5F5F5;strokeColor=#666666;fontStyle=1;html=1;" vertex="1" parent="1">
<mxGeometry x="50" y="50" width="300" height="200" as="geometry" />
</mxCell>
<!-- Firewall inside DMZ -->
<mxCell id="fw" value="Firewall" style="shape=mxgraph.cisco.firewalls.firewall;sketch=0;html=1;whiteSpace=wrap;" vertex="1" parent="dmz">
<mxGeometry x="100" y="60" width="80" height="60" as="geometry" />
</mxCell>
<!-- Internal Group -->
<mxCell id="internal" value="Internal Network" style="swimlane;startSize=25;fillColor=#DAE8FC;strokeColor=#6C8EBF;fontStyle=1;html=1;" vertex="1" parent="1">
<mxGeometry x="450" y="50" width="300" height="200" as="geometry" />
</mxCell>
<!-- Server -->
<mxCell id="srv" value="App Server" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D5E8D4;strokeColor=#82B366;" vertex="1" parent="internal">
<mxGeometry x="90" y="60" width="120" height="60" as="geometry" />
</mxCell>
<!-- Connection -->
<mxCell id="conn" style="endArrow=classic;startArrow=classic;html=1;strokeWidth=2;" edge="1" parent="1" source="fw" target="srv">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Example 4: Custom Metadata with UserObject
<mxfile>
<diagram id="metadata" name="Servers">
<mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="850" pageHeight="1100">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Server with custom attributes -->
<UserObject id="srv1" label="Web Server" tooltip="Production web server"
ip="10.0.1.10" environment="production" owner="ops-team">
<mxCell style="rounded=1;whiteSpace=wrap;html=1;fillColor=#D5E8D4;strokeColor=#82B366;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="140" height="70" as="geometry" />
</mxCell>
</UserObject>
<!-- Database with custom attributes -->
<object id="db1" label="PostgreSQL" ip="10.0.2.20"
environment="production" port="5432">
<mxCell style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#DAE8FC;strokeColor=#6C8EBF;" vertex="1" parent="1">
<mxGeometry x="350" y="90" width="100" height="90" as="geometry" />
</mxCell>
</object>
<mxCell id="conn1" style="endArrow=classic;html=1;" edge="1" parent="1" source="srv1" target="db1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
15. Additional mxGraphModel Attributes
These optional attributes on <mxGraphModel> are less commonly used but appear
in real-world files:
| Attribute | Values | Description |
|---|---|---|
adaptiveColors | auto, simple, none, default | Controls color adaptation for light/dark mode viewing |
backgroundImage | JSON | Background image of the page: {"src":"https://…","width":800,"height":600}. A background page is a page link: {"src":"data:page/id,PAGE_ID"} |
measureScale | number | Drawing scale for measurements in labels: 50 if one unit in the diagram is 50 units in reality. Default 1. Not in mxfile.xsd 1.0, so a file with it fails validation |
adaptiveColors example:
<mxGraphModel dx="0" dy="0" grid="1" ... adaptiveColors="auto">
AI generators typically do not need to set this attribute.
16. Validation Checklist for AI-Generated Files
Use this checklist to verify generated draw.io files:
- Valid XML: File is well-formed XML with proper escaping
- Root element:
<mxfile>as root, contains at least one<diagram> - Diagram IDs: Each diagram has a unique
idattribute - Structural cells: Root contains
<mxCell id="0"/>and<mxCell id="1" parent="0"/> - Unique IDs: All cell IDs are unique within the diagram
- Parent references: Every cell (except id="0") has a valid
parentreferencing an existing cell - Type flags: Each content cell has either
vertex="1"oredge="1"(not both) - Edge references: Edge
sourceandtargetreference existing vertex IDs - Geometry: Vertices have mxGeometry with x, y, width, height; edges have
relative="1" - Style format: Style strings use
key=value;format, valid keys and values - Perimeter match: Non-rectangular shapes have matching perimeter in style
- HTML escaping: HTML in
valueattributes is properly XML-escaped - Coordinate system: x increases right, y increases down, no negative dimensions
- Group hierarchy: Children of groups have coordinates relative to the group
- Page links: Every
data:page/id,link names theidof a<diagram>in the file - Link JSON: The JSON in
data:action/json,links and inanimationis valid, with"escaped as"