hkohlhoff133 downloadsCollapse and expand hierarchical branches in Obsidian Canvas.
Canvas Folding adds hierarchical folding, level views, and branch focus to the
standard Obsidian Canvas. It changes only the current view: nodes, edges,
content, positions, and the .canvas file itself remain untouched.
Requires Obsidian 1.13.0 or later. Canvas Folding works on desktop and mobile and has no dependency on Advanced Canvas.
The current plugin has been manually tested on:
The compact node-control geometry and its neutral highlight states were also verified with Obsidian's default theme, Minimal 9.0.2, and AnuPpuccin 1.5.0 on macOS, iPadOS, and iOS. The AnuPpuccin pass used Style Settings 1.0.9 with the maintained test profile.
If Canvas Folding is useful to you, you can support its continued development by buying me a coffee.
Canvas Folding does not require Advanced Canvas, but both plugins can remain enabled and work alongside each other. Canvas Folding 1.0.0 completed an extensive coexistence matrix with Advanced Canvas 6.5.4 and Obsidian 1.13.7 on macOS, iPadOS, and iOS.
The tests covered plugin load order and restarts, node and edge editing, different node types and shapes, nested groups, shared descendants, cycles, focus, levels, persistence, multiple Canvas tabs, undo/redo, and desktop and touch interaction. No unintended mutual interference was found in the supported standard Canvas features: each plugin retains its own controls and state, and using one plugin does not silently change the state owned by the other. See Using Canvas Folding with Advanced Canvas for the few details worth knowing when both plugins hide content.
Before the 1.1.0 release, the changed controls, connected groups, branch focus, shared-parent behavior, editing, undo/redo, and plugin lifecycle also passed a focused regression test with Advanced Canvas 7.0.0 on macOS.
Each eligible node shows its compact controls inside the upper-right corner,
beyond the native resize border. The − control collapses the complete directed
branch. Its replacement shows the total number of hidden nodes and groups, so
folded state stays readable across the Canvas. The control grows leftward for
two- or three-digit counts.
On desktop, pause the pointer over a folding control. Its tooltip states whether the click will collapse or expand the branch, breaks the hidden total down into nodes and groups, and points to the branch display menu.
The tooltip is especially useful with Advanced Canvas: if an Advanced Canvas group currently hides descendants, it says how many are hidden there and explains that Canvas Folding preserves the group's own collapsed state.
On touch devices, where hover is unavailable, long-press the control; an Advanced Canvas notice with the hidden-descendant count appears at the top of the branch display menu.
Right-click or long-press a node control to show only the parent, reveal a specific number of descendant levels, or show the entire branch.
Focus mode keeps the selected branch fully active while dimming and protecting the surrounding Canvas. The wider context remains visible without distracting from the branch being worked on.
Use the focus symbol on any node or group to enter focus directly. Items without children receive the same control, so they can be focused individually. Click the active focus control again, or use the toolbar focus action, to exit. Focusing a group keeps the group and every item geometrically contained by it fully active while unrelated Canvas content is dimmed.
− control, or select the parent and use the Canvas
Folding toolbar. Right-click or long-press the control to choose a visible
branch level.Canvas Folding interprets directed Canvas edges as hierarchy:
fromNode → toNode. A node can therefore have multiple parents, and the
Canvas is treated as a general directed graph rather than as a strict tree.
Traversal is deterministic and cycle-safe.
Global Canvas levels are measured from root nodes, meaning nodes without an incoming edge. Level 0 contains the roots, level 1 their direct children, and each following level the next generation of directed descendants. If a node is reachable through multiple roots or paths, its shortest directed distance from any root determines its level. A Canvas without a root has no global level view, but its individual branch controls remain available.
Parent nodes receive a directly visible folding control inside their upper-right corner. When descendants are hidden, it displays the total number of hidden nodes and groups. The tooltip reports both categories separately:
Every visible, expanded node and group also receives a focus control. A
collapsed parent shows only its folding control; its focus control returns when
the branch is expanded, provided focus controls are enabled. Folding controls
and focus controls can be hidden independently through the toolbar or command
palette. Hiding either kind of control changes only the interface: it does not
expand branches or end an active focus.
On touch devices, the same compact controls remain directly available without
selection; the Canvas toolbar provides an additional route for selected-branch
actions. Controls occupy only the upper-right interior, leaving the complete
node border available for native resizing. Folded branches keep their count or
+ indicator visible across the Canvas.
When a group is focused, its geometrically contained items belong to the focus
area even when they have no directed edge from that group.
When Advanced Canvas collapses one of its groups, Canvas Folding removes both of its controls from that compact group representation. The controls return after Advanced Canvas expands the group again.
Hidden nodes also hide every incident edge, including edge labels. A collapsed branch connection can remain hidden while its shared endpoint stays visible through another open parent. An unconnected non-empty Canvas group is hidden when all non-group nodes geometrically contained by it are hidden. A group connected through directed edges follows its own branch instead: hiding a separate branch inside it does not hide the group frame. Empty groups remain visible unless the group itself is a directed descendant of a folded parent. When a group is hidden as such a descendant, every node geometrically contained by it is hidden as well, even without a separate parent edge. If this makes every descendant of another visible node unavailable, that node's folding control stays in place but is disabled with the explanation Branch hidden by folded group. Its existing branch state is preserved and the control becomes active again when the group branch is expanded.
The optional toolbar provides the main Canvas Folding actions directly in the Canvas. Drag its handle to move it, or focus the handle and use the arrow keys. On narrow views and mobile devices, the toolbar can be scrolled horizontally.
The toolbar includes actions for:
Unavailable actions are disabled. The toolbar can always be shown, hidden, toggled, or reset through the command palette.
All commands are available from the command palette when their Canvas context is valid:
| Command | Purpose |
|---|---|
Collapse selected branch |
Hide all directed descendants of the selected node. |
Expand selected branch |
Reveal the folded branch at the selected node. |
Focus selected branch |
Keep the selected node and descendants active while dimming the rest. |
Exit branch focus |
Remove focus without changing the underlying fold state. |
Collapse all branches |
Collapse every rooted branch. |
Show canvas through level… |
Set one visible depth for all rooted branches. |
Expand all branches |
Clear all folding and level restrictions. |
Show branch controls |
Display folding controls on parent nodes. |
Hide branch controls |
Hide folding controls in the current session without changing folded branches. |
Toggle branch controls |
Switch the branch controls between visible and hidden. |
Show focus controls |
Display focus controls on visible, expanded nodes and groups, including leaves. |
Hide focus controls |
Hide focus controls without ending an active focus. |
Toggle focus controls |
Switch the focus controls between visible and hidden. |
Show canvas toolbar |
Display the Canvas Folding toolbar. |
Hide canvas toolbar |
Hide the Canvas Folding toolbar. |
Toggle canvas toolbar |
Switch the Canvas Folding toolbar between visible and hidden. |
Reset canvas toolbar position |
Return the toolbar to its default position. |
Inspect active canvas graph |
Report the recognized graph structure. |
Show current status |
Report visible-state counts, focus, controls, and persistence status. |
Node controls follow a depth-first Tab order. On a node, its focus control comes before its folding control. Upper child branches are visited completely before lower sibling branches. If exactly one node is selected, navigation starts at that node's first available control.
Enter or Space activates a node control or toolbar action.Node controls keep their compact desktop size on coarse-pointer devices so they cover less card content; Canvas zoom remains available for closer touch interaction. The toolbar supports horizontal touch scrolling and dragging. Canvas node selection remains native on iPhone and iPad. Long-press access to the branch-level menu depends on whether the installed Obsidian/WebView version emits a context-menu event.
By default, fold state, level restrictions, temporary branch-display exceptions, and branch focus are remembered only in the open Canvas tab. Navigating to another file and back in that tab restores its state; closing the tab discards it.
Enable Remember canvas states between sessions to also restore state in new
tabs and after restarting Obsidian or the plugin. The data is stored in Canvas
Folding's local data.json, never in the .canvas file. Entries for deleted or
renamed Canvas files and stale node IDs are cleaned automatically and can also
be reviewed or removed from the settings.
Canvas Folding does not synchronize settings or persisted states between
devices. They belong to the local Obsidian plugin configuration, so the same
Canvas can intentionally have different folding states on a Mac, iPhone, and
iPad. If Obsidian Sync or another synchronization system is configured to sync
plugin settings and data, it may also transfer Canvas Folding's data.json;
that behavior is controlled by the synchronization setup, not by Canvas
Folding.
After Canvas Folding is listed, install it directly from Obsidian Community Plugins.
Until then, or for a manual installation, download main.js, manifest.json,
and styles.css from a GitHub release and place them in:
<vault>/.obsidian/plugins/canvas-folding/
Then reload Obsidian and enable Canvas Folding under Community plugins.
The repository includes a documented demo covering a basic tree, a shared
descendant, a cycle, an isolated node, groups, and different node types:
examples/Canvas Folding Demo/.
Copy the complete Canvas Folding Demo folder to the root of a vault and
open Canvas Folding Demo/Canvas Folding Demo.canvas. The explanatory cards
on the Canvas suggest actions and describe the expected result.
Focused regression fixtures and the full manual V1 test matrix remain
separately available under manual-tests/.
The settings page starts with a reminder that Canvas Folding never modifies Canvas files.
After an update with new user-facing features, Canvas Folding opens a
Markdown-rendered What's new view once. Closing it removes the view
completely; no release-note file is created in the Vault and it does not reopen
on every Obsidian start.
Use Show last update at the bottom of the plugin settings to open the
description again at any time. Use Show readme beside it to open this
complete documentation locally inside Obsidian. The repository keeps the same
text in Last Update.md.
Canvas Folding works entirely locally and sends no Canvas or vault data to external services. The Ko-fi image in this README is documentation content and is not loaded or contacted by the installed plugin.
When persistence is enabled, local plugin data contains vault-relative Canvas paths, node IDs, and visibility settings. Canvas files themselves are never modified by Canvas Folding.
Canvas Folding and Advanced Canvas can hide content independently. Canvas
Folding hides directed branches only in the current view and keeps its state in
the open tab or, optionally, in Canvas Folding's data.json. Advanced Canvas'
collapsible groups have their own controls and store their group state in the
Canvas data.
When both mechanisms are used, check which control owns the hidden content:
− can remain visible while an Advanced Canvas group hides
descendants inside it; the control's tooltip explains this case.After enabling or disabling Advanced Canvas while one of its groups is collapsed, close and reopen the Canvas before continuing to edit. The already open view can temporarily retain Advanced Canvas group controls or show an empty group frame. Reopening rebuilds the Canvas view from the stored data.
Other plugins can optionally discover Canvas Folding by the stable plugin ID
canvas-folding. The read-only CanvasFoldingApi v1 returns effective hidden
node and edge IDs for a vault-relative Canvas path. It exposes no DOM elements,
Canvas views, workspace leaves, or internal state classes.
See docs/api.md for the complete contract and a defensive
discovery example. Consumers must remain functional when Canvas Folding is not
installed, disabled, or exposes an incompatible API version.
Requires Node.js 20.19 or later.
npm ci
npm test
npm run build:prod
For local deployment, set OBSIDIAN_PLUGINS_DIR to a test vault's plugin
directory:
OBSIDIAN_PLUGINS_DIR="/path/to/vault/.obsidian/plugins" npm run build:prod:deploy
The production release contains main.js, manifest.json, and styles.css.
See CONTRIBUTING.md and
docs/release-checklist.md for development and
release checks.
Please report reproducible problems and feature requests through the GitHub issue tracker.
Canvas Folding is licensed under the GNU General Public License v3.0 or later.