An identical feature now exists in ComfyUI. Additionally, this extension is largely broken with the recent versions of the codebase, so please use the built-in feature for group nodes.
Adds a feature for the default interface in ComfyUI that allows for nesting of other nodes for better organization and simplification of repetitive patterns in workflows.
This is a prototype and will likely have many problems. This will probably be obsolete once subgraphs are implemented within ComfyUI. To be safe, save your workflow before nesting any nodes. How nested nodes are saved are subject to change and saved nodes may become unusable in the future.
Enter the following command from the commandline starting in ComfyUI/custom_nodes/
git clone https://github.com/ssitu/ComfyUI_NestedNodeBuilder
1. Selecting the nodes to nest
Select multiple nodes by usingCtrl/Shift + left/right click
on the desired nodes to nest.
You can also use Ctrl + left click + drag
to highlight nodes.
2. Nesting the selected nodes
After making a selection,right click
on any of the selected nodes and select Nest Selected Nodes
and choose a name that won't conflict with any other existing node. The selected nodes will be replaced with a new node that contains the selected nodes. You can also unnest the new node by right clicking on the node and clicking Unnest
. The selected nodes may also be converted to an already existing nested node using the Convert selected to Nested Node: <name>
option that appears if the selected nodes have a similar structure.
3. Creating a nested node from the node menu
Nested nodes are saved and can be created again from the node menu that appears when youright click
on the canvas under the Nested Nodes
category.
4. Where are nested nodes saved?
You can find them underComfyUI/custom_nodes/ComfyUI_NestedNodeBuilder/nested_nodes/
. This directory can be changed by editing the nested_nodes_path
entry in the config.yaml
. The nested nodes are stored as .json files. The names of the nested nodes may be changed by editing their .json files. The changes made to the directory are registered after refreshing the web UI.
The nodes that are nested are stored in the properties of the nested node. Before the prompt is calculated, the nested node is replaced with the nodes that it stored. After the prompt is calculated, the nodes are nested again. Depending on performance, this may cause a quick flash of what the workflow looks like after the nodes are unnested when queueing a prompt. This seemed to be the approach that was the least intrusive on the ComfyUI codebase.
- Nested nodes cannot be nested themselves.
- When converting a seed widget to input and connecting it to a primitive node, the prompt will ignore the control_after_generate widget of the primitive node and yield to the underlying control_after_generate widget of the respective node. Can be solved by changing the values to "fixed" before nesting.
- Can't really nest output nodes such as preview image and save image nodes. It works, but it won't display the image.
Feel free to open an issue if you find any other problems.
Inspired by this repo by ltdrdata, check it out if you want something more robust and flexible.