What is a Subgraph?
It is a function to aggregate multiple nodes into one node. Not only does it clean up the appearance, but it can also be saved as a reusable module (Blueprint) and handled like a new node.
It is possible to summarize all nodes into one, but ComfyUI is characterized by being able to divide the image generation pipeline into small modules.
Personally, I consider it a function to create "reusable modules" rather than just cleaning up the appearance.
Creating a Subgraph
-
- Select multiple nodes you want to group
-
- Click
🕸️(Convert Selection to Subgraph) inNode Selection Toolbox
- Click
Editing a Subgraph
Enter edit mode by double-clicking the subgraph or clicking the icon on the upper right.
Basic operations are the same as usual, but parameters to interact with the outside need to be connected to the input/output slots (left end/right end) of the subgraph.
Parameter Publication Settings
You can expose parameters inside the subgraph as widgets of the subgraph node. You can change values without entering edit mode every time.
-
- Select Subgraph
-
- Click
Edit Subgraph WidgetsinNode Selection Toolbox
- Click
-
- Check the parameters you want to publish
Saving and Reusing Subgraphs
If you save the created subgraph, you can reuse it as a unique node.
-
- Select Subgraph
-
- Click
📖(Publish Subgraph) inNode Selection Toolbox
- Click
-
- Enter name and
Confirm
- Enter name and
After saving, you can call it by searching (double clicking) just like a normal node.
You can also check it from the node library in the sidebar, and delete/edit the Blueprint from here.
{
"id": "a3364ead-7493-4912-8d6a-93d97d396e56",
"revision": 0,
"last_node_id": 23,
"last_link_id": 25,
"nodes": [
{
"id": 5,
"type": "JoinImageWithAlpha",
"pos": [
1674.6447738961886,
632.3248013583096
],
"size": [
176.86484375,
46
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2
},
{
"name": "alpha",
"type": "MASK",
"link": 25
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
20
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.51",
"Node name for S&R": "JoinImageWithAlpha"
},
"widgets_values": []
},
{
"id": 1,
"type": "LoadImage",
"pos": [
982.0730322265621,
631.4157104492188
],
"size": [
347.95306396484375,
453.8662109375
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
2,
21
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.51",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"GB_test.png",
"image"
]
},
{
"id": 22,
"type": "bfc1244e-11c7-4ffd-a074-4342a2b8fddd",
"pos": [
1405.5464394992873,
755.382677721946
],
"size": [
212,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 21
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
25
]
}
],
"properties": {
"proxyWidgets": [
[
"4",
"red"
],
[
"4",
"green"
],
[
"4",
"blue"
]
],
"cnr_id": "comfy-core",
"ver": "0.3.71"
},
"widgets_values": []
},
{
"id": 21,
"type": "PreviewImage",
"pos": [
1884.7735019531228,
631.4157104492188
],
"size": [
377.09303778542335,
438.18338923496117
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 20
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
2,
1,
0,
5,
0,
"IMAGE"
],
[
20,
5,
0,
21,
0,
"IMAGE"
],
[
21,
1,
0,
22,
0,
"IMAGE"
],
[
25,
22,
0,
5,
1,
"MASK"
]
],
"groups": [],
"definitions": {
"subgraphs": [
{
"id": "bfc1244e-11c7-4ffd-a074-4342a2b8fddd",
"version": 1,
"state": {
"lastGroupId": 0,
"lastNodeId": 14,
"lastLinkId": 17,
"lastRerouteId": 0
},
"revision": 0,
"config": {},
"name": "Chroma Key",
"inputNode": {
"id": -10,
"bounding": [
1240.5157470703125,
757.3956909179688,
120,
60
]
},
"outputNode": {
"id": -20,
"bounding": [
2252.8402709960938,
757.3956909179688,
120,
60
]
},
"inputs": [
{
"id": "1d817b72-4293-49a6-a5b2-49f2109c07a7",
"name": "images",
"type": "IMAGE",
"linkIds": [
1
],
"localized_name": "images",
"pos": [
1340.5157470703125,
777.3956909179688
]
}
],
"outputs": [
{
"id": "25a7349f-9f55-4a69-9b31-f9916122c40a",
"name": "MASK",
"type": "MASK",
"linkIds": [
14
],
"localized_name": "MASK",
"pos": [
2272.8402709960938,
777.3956909179688
]
}
],
"widgets": [],
"nodes": [
{
"id": 11,
"type": "GrowMask",
"pos": [
1725.345458984375,
713.3956909179688
],
"size": [
220.4611358642578,
82
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"localized_name": "mask",
"name": "mask",
"type": "MASK",
"link": 11
}
],
"outputs": [
{
"localized_name": "MASK",
"name": "MASK",
"type": "MASK",
"links": [
13
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.51",
"Node name for S&R": "GrowMask"
},
"widgets_values": [
6,
true
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 13,
"type": "ImpactGaussianBlurMask",
"pos": [
1980.63623046875,
713.3956909179688
],
"size": [
212.20404052734375,
82
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"localized_name": "mask",
"name": "mask",
"type": "MASK",
"link": 13
}
],
"outputs": [
{
"localized_name": "MASK",
"name": "MASK",
"type": "MASK",
"links": [
14
]
}
],
"properties": {
"cnr_id": "comfyui-impact-pack",
"ver": "f86c5afc68958afb89bf66898d6b5038ce98a096",
"Node name for S&R": "ImpactGaussianBlurMask"
},
"widgets_values": [
2,
5
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 4,
"type": "ColorToMask",
"pos": [
1420.5157470703125,
713.3956909179688
],
"size": [
270,
178
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [
{
"localized_name": "images",
"name": "images",
"type": "IMAGE",
"link": 1
}
],
"outputs": [
{
"localized_name": "MASK",
"name": "MASK",
"type": "MASK",
"links": [
11
]
}
],
"properties": {
"cnr_id": "comfyui-kjnodes",
"ver": "e2ce0843d1183aea86ce6a1617426f492dcdc802",
"Node name for S&R": "ColorToMask"
},
"widgets_values": [
false,
0,
255,
0,
10,
16
],
"color": "#232",
"bgcolor": "#353"
}
],
"groups": [],
"links": [
{
"id": 11,
"origin_id": 4,
"origin_slot": 0,
"target_id": 11,
"target_slot": 0,
"type": "MASK"
},
{
"id": 13,
"origin_id": 11,
"origin_slot": 0,
"target_id": 13,
"target_slot": 0,
"type": "MASK"
},
{
"id": 1,
"origin_id": -10,
"origin_slot": 0,
"target_id": 4,
"target_slot": 0,
"type": "IMAGE"
},
{
"id": 14,
"origin_id": 13,
"origin_slot": 0,
"target_id": -20,
"target_slot": 0,
"type": "MASK"
}
],
"extra": {}
}
]
},
"config": {},
"extra": {
"ds": {
"scale": 0.9782323058636119,
"offset": [
-182.127744825944,
-320.97800794421806
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}