Skip to content
ComfyUI Wiki
Help Build a Better ComfyUI Knowledge Base Become a Patron
💡

The Subgraph feature requires at least ComfyUI frontend version 1.24.3. If you don’t see this feature in your ComfyUI, please refer to this document for updates: How to Update ComfyUI

  • The example images in this article are made using the nightly frontend version, please refer to the actual interface
  • Some features like converting subgraphs back to regular nodes will be improved in future versions
ComfyUI Subgraph Feature

Subgraph is a very practical workflow feature in ComfyUI that helps you package complex workflows into independent nodes, making the entire workflow more concise and easier to manage.

Subgraph

Simply put, subgraphs are like “folders” in workflows. You can organize a series of related nodes together and then operate the entire combination like using a single node. This approach makes complex workflows clearer and easier to understand.

Using the subgraph feature, you can achieve the following goals:

  • Simplify complex workflows and improve readability
  • Easily reuse common node combinations and avoid repetitive operations
  • Create modular node combinations to improve workflow building efficiency

How to Create a Subgraph?

Select Target Nodes

In the ComfyUI interface, first select the nodes you want to combine into a subgraph

Click the Subgraph Function Button

Subgraph icon Find the subgraph function icon in the selection toolbar and click it

Complete Subgraph Creation

Workflow using subgraph ComfyUI will automatically analyze the input-output relationships of the selected nodes and create a new subgraph node to add to the canvas.

Optimize Subgraph Structure

Workflow using subgraph Through further editing and adjustment, you can optimize the subgraph into a functionally complete and structurally clear node module.

Detailed Subgraph Editing Features

1. Basic Editing Operations

Subgraph nodes have the same editing functions as regular nodes. You can perform the following operations:

  1. Adjust node colors and appearance
  2. Modify node names and labels
  3. Use the Bypass function to temporarily disable
  4. Other regular node operations

2. Deep Editing of Subgraphs

To enter the detailed editing mode of a subgraph, you can:

  • Double-click the mouse in the non-component area of the subgraph node
  • Or click the edit button on the subgraph

The interface after entering edit mode is as follows: Editing subgraph

Interface Element Description:

  1. Navigation Bar: Shows the current subgraph level and allows quick return to the upper-level workflow
  2. Input Slots: Connection points for receiving external data
    • You can connect outputs from other nodes to these slots
    • Right-click on connection points to rename or delete slots
  3. Output Slots: Connection points for sending data to external sources, with similar functions to input slots

Subgraph slots

Slot Operation Guide:

  1. Slots marked with number 1 are default slots: Used to add new input or output connections to expose internal nodes to the outside
  2. Right-click on existing slots to perform operations such as renaming, deleting, or canceling connections

Note: Slot connections also need to follow data type matching rules

3. Subgraph Nesting Function

Subgraphs support multi-level nesting, which means you can create other subgraphs inside a subgraph, thus building more complex and modular workflow structures.

Nested subgraph

When editing nested subgraphs, the system provides multi-level navigation functions to help you quickly switch and return between different levels.

Nested subgraph navigation

💡

Current version does not yet support link instances, synchronous editing, etc. These features will be improved in future versions