Create and edit Obsidian Canvas files for architecture visualization
Create and edit Obsidian Canvas files (.canvas JSON format) for architecture visualization.
Use when creating or editing .canvas files (Obsidian Canvas format):
The Obsidian linter will corrupt .canvas files if enabled. If you have a linter active (prettier, eslint, etc.):
.canvas filesThe linter will delete nodes with empty fields and reduce complex diagrams to 2 nodes.
textEvery node MUST use text property for content (NOT label):
{
"nodes": [
{
"id": "unique-id",
"type": "text",
"x": 0,
"y": 0,
"width": 200,
"height": 100,
"color": "3",
"text": "Node Content\nMultiline supported\nWith \\n character"
}
],
"edges": [
{
"id": "edge-id",
"fromNode": "node-id-1",
"toNode": "node-id-2",
"fromSide": "right",
"toSide": "left",
"label": "Edge Label"
}
],
"metadata": {
"version": "1.0-1.0",
"frontmatter": {}
}
}
Node Properties:
| Property | Required | Type | Values | Notes |
|---|---|---|---|---|
id | ✅ | string | Any unique ID | Use kebab-case |
type | ✅ | string | "text" | Currently only text type supported |
x | ✅ | number | Any integer | Canvas X coordinate |
y | ✅ | number | Any integer | Canvas Y coordinate |
width | ✅ | number | Any positive int | Node width in pixels |
height | ✅ | number | Any positive int | Node height in pixels |
text | ✅ | string | Any text | USE THIS FOR NODE CONTENT (not label) |
color | ❌ | string | "1"-"6" | Color: 1=red, 2=orange, 3=yellow, 4=purple, 5=cyan, 6=green |
Edge Properties:
| Property | Required | Type | Values |
|---|---|---|---|
id | ✅ | string | Any unique ID |
fromNode | ✅ | string | ID of source node |
toNode | ✅ | string | ID of target node |
fromSide | ✅ | string | "top", "right", "bottom", "left" |
toSide | ✅ | string | "top", "right", "bottom", "left" |
label | ❌ | string | Any text |
Metadata:
"metadata": {
"version": "1.0-1.0",
"frontmatter": {}
}
label for node content{"id":"node1","type":"text","x":0,"y":0,"width":100,"height":50,"label":"Node Text"}
Result: Text appears on edges, boxes are empty
text for node content{"id":"node1","type":"text","x":0,"y":0,"width":100,"height":50,"text":"Node Text"}
Result: Text displays inside the box
text field{"id":"node1","type":"text","x":0,"y":0,"width":100,"height":50,"text":""}
Result: Obsidian deletes the node on next edit
Only include properties with values. Don't include text field if empty.
Plan the canvas:
Example structure:
SECTION HEADERS (120px high, wide)
↓
MAIN NODES (100+ px high, sized to fit content)
↓
EDGES with labels connecting them
Example grid:
(0,0) (300,0) (600,0) (900,0)
A B C D
(0,100) (300,100) (600,100) (900,100)
E F G H
Size nodes based on content:
Add ~10-15px padding for text overflow.
Use text property for all node content. Use label property for edge labels only.
.canvas filenode -e "JSON.parse(require('fs').readFileSync('file.canvas'))"All of these use correct JSON Canvas format:
Canvas - C4 Context Diagram - 9 nodes, 9 edgesCanvas - System Landscape - 18 nodes, 14 edgesCanvas - Data Flow Diagram - 22 nodes, 18 edgesCanvas - AWS Architecture - 24 nodes, 11 edgesCanvas - Scenario Comparison - 19 nodes, 2 edgesCanvas - Data Platform Data Flow - 38 nodes, 68 edgesAll use text property for node content and label property for edge labels.
Canvas supports 6 colors:
Width:
Height:
Before considering a canvas file "done":
text propertylabel propertytext fields exist/diagram - Generate diagrams programmatically using Python/scenario-compare - Create side-by-side scenario comparison canvases/impact-analysis - Visualize system impact on canvasCanvas - {{Diagram Name}}.canvas
Canvas - C4 Context Diagram.canvas
Canvas - System Landscape.canvas
Canvas - Data Flow Diagram.canvas
Canvas - AWS Architecture.canvas
Quick validation command:
node -e "try { JSON.parse(require('fs').readFileSync('file.canvas', 'utf8')); console.log('✓ Valid JSON'); } catch(e) { console.log('✗ Error:', e.message); }"
Key Principle: text = node content, label = edge labels. Never use label for node content.
Key Warning: Disable linters before editing .canvas files - they corrupt the JSON structure.