ComfyUI_frontend icon indicating copy to clipboard operation
ComfyUI_frontend copied to clipboard

Exporting Subgraphs as custom nodes

Open comfy-pr-bot opened this issue 1 month ago • 3 comments

Feature Idea

Subgraph is a great encapsulation tool, but it lacks GLOBALITY. They are nice:

  • helps to hide all the wires
  • refuse variables nodes
  • allows to edit workflow comfortly in logical parts of it

But they are just GROUPS that got collapsed in nodes and encapsulated parameters and outputs.

For now they work like:

inputs = [1, 2, 3]
print(str(1) + ": " + inputs[0])
print(str(2) + ": " + inputs[1])
print(str(3) + ": " + inputs[2])

But it would be nice to work like this:

inputs = [1, 2, 3]
def f(idx, value):
  print(str(idx) + ": " + value)
f(1, inputs[0])
f(2, inputs[1])
f(3, inputs[2])

I.E. What i want is literally making FUNCTIONS for workflows, that can be edited in one place and will be applied all over the workflow (Or all over the workflows). I see this as local "composite nodes" and as composite workflows that can be exported from other workflows and used in other places.

It solves:

  • When I duplicate a subgraph, it becomes a separate entity. Video: https://github.com/user-attachments/assets/9fba5e8d-cb8f-4b37-89e8-4865d226a2e1
  • Any changes must be applied manually to each copy.

Existing Solutions

No response

Other

No response


This issue is transferred from: https://github.com/comfyanonymous/ComfyUI/issues/9340

Original issue was created by @AlexMorgan3817 at 2025-08-14T19:39:21.000Z

Original Comments:

@comfyui-wiki:

I think this feature is already part of our development plan.

┆Issue is synchronized with this Notion page by Unito

comfy-pr-bot avatar Oct 30 '25 04:10 comfy-pr-bot

And while we're at it, allow them to be bundled with custom node packs. This would help a lot to strike a balance between providing a lot of low-level nodes to be flexible versus providing monster nodes which only serve one purpose well.

Example: https://github.com/geroldmeisinger/ComfyUI-outputlists-combiner/tree/main#combine-rowcolumn-for-filename

Image

I developed these String OutputList and OutputList Combinations nodes. I really would like to combine the patterns String OutputList + StringOutputList > OutputList Combinations > Formatted String (for a prompt combiner subgraph) and Number OutputList + Number OutputList > OutputList Combinations > Formatted String (for a row/column printer), ship them together with the custom node pack, while still providing the users the possibility to inspect the subgraph and customize.

geroldmeisinger avatar Nov 30 '25 10:11 geroldmeisinger

@geroldmeisinger That would be nice, definitely. It's worth noting that you can use Node Expansion to do a lot of that. https://docs.comfy.org/custom-nodes/backend/expansion

A number of my own custom nodes use GraphBuilder to combine other nodes.

That wouldn't let users inspect and modify it, though.

arcum42 avatar Nov 30 '25 10:11 arcum42

@arcum42 The docs are sparse but if I understand it correctly the expansion only happens virtually/functionally not visually (i.e. it doesn't pop-out into 5 nodes in the workflow). So essentially this contributes another custom node which overcrowds the search list more. And the same can be done in code anyway, the only advantage is the automatic caching of heavy nodes. I would also like to keep nodes and patterns/subgraphs separate (although subgraph blueprints already appear in the list, so the separation is only categoral).

geroldmeisinger avatar Nov 30 '25 10:11 geroldmeisinger

+1 Blueprint instances should be linked to their 'blueprint'... same way how BPs behave in Unreal Editor

yingDev avatar Dec 01 '25 14:12 yingDev