Send the first valid value from input to the output
The fallback switch that never needs a selector
- input_a
- input_b
- input_c
- input_d
- output
The single most useful wiring pattern in ComfyUI is the fallback: several optional branches feeding one downstream consumer, where whichever branch is actually alive wins. You don't want to flip a selector - you want the graph to decide. This node is exactly that pattern, with four inputs and no selector at all: it walks input_a through input_d and passes through the first one that isn't None.
Think of the shape it enables. You've got a reference image that sometimes comes from a loader and sometimes from a batch, or a prompt that can arrive from three different upstream branches depending on which part of the workflow is active. Wire all the candidates into this node's four inputs, and the output is "whichever one is live." No manual switches, no conditional logic nodes, no way to get it wrong at runtime. This is the rgthree-Any Switch-style pattern, implemented as a small standalone node - it's the kind of plumbing that removes whole classes of "I forgot to flip the switch" bugs.
How it works
The mechanism is the ComfyUI convention that unconnected optional inputs arrive as None. The node checks each input in order - input_a, then input_b, then input_c, then input_d - and returns the first one that is not None. If all are empty, it returns None, which is a valid output (it lets downstream optional inputs stay disconnected, the "null-output placeholder" trick).
Two details worth knowing:
- All four inputs are wildcard-typed (
*), so they can carry any type - but that also means they should all be the same type for downstream sanity. This node won't stop you from mixing an IMAGE into input_a and a STRING into input_b; it'll just pass whichever is first and let the downstream node choke if the types conflict. - It declares an
IS_CHANGEDmethod that hashes the inputs, so it re-evaluates correctly when candidates change - no stale fallback values.
The inputs that matter
input_athroughinput_d- the candidates, checked in order. That order is the whole product:awins if present, thenb, thenc, thend.
One output: output, the first valid value.
Installing it
Part of ComfyUI-Przewodo-Utils. ComfyUI Manager → search the pack, or:
cd ComfyUI/custom_nodes
git clone https://github.com/przewodo/ComfyUI-Przewodo-Utils.git
Restart. No extra dependencies.
Where people get tripped up
The output-node detail is the surprising one: this node is registered with OUTPUT_NODE = True, which means ComfyUI treats it as a terminal/output node and it always runs. In practice that's harmless - it just re-executes each run - but it's why you might see it marked as an output in the UI even though you're using it mid-graph.
And the type-purity warning again: this node is type-agnostic by design, so it can't catch mismatches for you. If your fallback candidates are different types, the failure will show up downstream, confusingly, instead of at this node. Keep your inputs homogeneous and this thing is a quiet workhorse; let types drift and it becomes the culprit in a mystery you'll blame on something else.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| input_aopt | * | — | |
| input_bopt | * | — | |
| input_copt | * | — | |
| input_dopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |