apply_layout
Applies automatic layout algorithms to organize diagram nodes. Choose from hierarchical, organic, tree, radialTree, or circle to restructure your draw.io diagram automatically.
Instructions
Trigger a draw.io built-in automatic layout algorithm on the diagram. Requires the diagram to be open in VS Code with the companion extension connected.
Available layouts:
"hierarchical": Best for flowcharts, org charts, architecture diagrams. Arranges nodes in layers by rank.
"organic": Force-directed layout. Good for graphs with many cross-connections. Nodes spread out naturally.
"tree": Compact tree layout. Best for strict tree/hierarchy structures.
"radialTree": Tree layout radiating outward from center.
"circle": Arranges all nodes in a circle.
After layout, draw.io saves the updated positions back to the .drawio file automatically.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| layout | Yes | Layout algorithm to apply | |
| spacing | No | Primary spacing between nodes in px (default: layout-dependent, typically 30-50) | |
| filePath | No | Path to the .drawio file (scopes layout to the correct editor) | |
| direction | No | Layout direction (default: vertical). Only applies to hierarchical and tree layouts. | |
| interRankSpacing | No | Spacing between ranks/layers in px (default: layout-dependent). Only for hierarchical and tree. |