Dynamic Image Router
Ten image outputs, exactly one carries data
- images
- out_1
- out_2
- out_3
- out_4
- out_5
- out_6
- out_7
- out_8
- out_9
- out_10
You've built the workflow where several different branches can feed one downstream pipeline - different loaders, different generation branches - and you'd like one integer to decide which one wins. That's this node: it takes a single IMAGE batch in and routes it to exactly one of ten numbered outputs, out_1 through out_10, picked by the select_path widget.
The part that makes it useful rather than just a bunch of wires is how it blocks the other nine. The unselected outputs use ComfyUI's ExecutionBlocker mechanism, which means anything downstream of them doesn't just receive empty data - it never executes at all. A node on an unselected branch that does image[0] instead of image[:1] won't crash, because that node never runs. That's the difference between "routing" and "silently handing empty tensors to a graph that will choke on them."
Inputs and outputs are minimal:
images- theIMAGEbatch you're routing.select_path- integer 1–10, default 1. That's the whole control surface.out_1…out_10- allIMAGE. Exactly one carries your batch; the other nine are blocked.
There's a real use case here beyond tidiness. If you have several image sources (or upstream generation branches) feeding one downstream stage, wiring them through this lets you switch with a single integer without the unused branches burning compute - and, more importantly, without Preview/SaveImage nodes on unused branches throwing errors for their share of the run. It's the image-side cousin of the sampler/model switch nodes in the same pack, all built on the same lazy-execution idea.
Installation is the pack standard:
cd ComfyUI/custom_nodes
git clone https://github.com/jjmaden/comfyui-jjmaden-random-nodes
Restart ComfyUI afterward, or install via ComfyUI Manager by searching "JJMaden Random Nodes". MIT, no extra Python dependencies, no models to download - this is a small personal pack (author jjmaden), so the "docs" are the README and the node's own description.
The one real caveat is the fallback path. If your ComfyUI build predates ExecutionBlocker, the node can't stop execution, so it hands unselected outputs an empty (0, 64, 64, 3) image tensor instead. Nodes that loop over a batch - PreviewImage, SaveImage, VAEEncode - handle that fine. Anything that indexes with image[0] on that fallback path can still error. If you're on an older ComfyUI and see weird failures on branches you didn't select, update ComfyUI; the blocking behavior is the whole point.
The one thing to keep in mind: select_path is a widget, not an input socket, so you can't drive it from another node or an API field. If you genuinely need it driven dynamically, convert the widget to an input - that works for any ComfyUI node. For the everyday "swap which source feeds this pipeline" job, though, it's a clean, unpretentious node that does exactly what it says.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| select_path | INT | 11–10 | — |
Outputs (10)
| Name | Type | Description |
|---|---|---|
| out_1 | IMAGE | — |
| out_2 | IMAGE | — |
| out_3 | IMAGE | — |
| out_4 | IMAGE | — |
| out_5 | IMAGE | — |
| out_6 | IMAGE | — |
| out_7 | IMAGE | — |
| out_8 | IMAGE | — |
| out_9 | IMAGE | — |
| out_10 | IMAGE | — |