Conditional Select
A ternary operator that only runs the branch you pick
- value_if_true
- value_if_false
- result
_ConditionalSelect is ComfyUI's version of a ternary: result = value_if_true if condition else value_if_false. That's the whole node - three inputs, one output. What makes it worth a page is the detail most people never notice: it's lazy. Only the branch you actually pick gets evaluated. That one property is why it can safely sit inside a loop's control flow, and it's genuinely handy outside loops too.
What it does
You give it a condition (boolean), a value_if_true, and a value_if_false, and you get the selected value out. Nothing surprising. The lazy part is the trick. ComfyUI normally resolves every input before a node runs - which means if your value_if_false is the result of a long expensive chain, you pay for it even when the condition is true. _ConditionalSelect tells ComfyUI's execution engine to skip that chain when it isn't needed: it requests only the input it's actually going to return, so the unselected branch never runs at all.
In a loop that matters twice over. First, it's what makes the early-stop mechanism cheap: TensorLoopClose builds a "stop or continue?" condition and selects between an exit path and a continue path - the path not taken isn't computed. Second, it prevents whole classes of "this node got None and crashed" errors, because the branch that would produce a useless value simply isn't executed.
Inputs and outputs
- condition (boolean) - which branch to take.
- value_if_true (any) - returned when condition is true.
- value_if_false (any) - returned when condition is false.
- result - whatever you selected.
Any type works - tensors, latents, ints, strings, even the loop-state dicts this pack passes around. That's why the loop machinery uses it for everything from the bypass path (iterations = 0 → just pass through) to the "no progress, stop the loop" bail-out.
Install
Same as every node in the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-NativeLooping_testing
Restart ComfyUI, or search "NativeLooping" in Manager. Dev-only, so it's hidden from the menu - you'd have to add it from a workflow that already contains it.
If you want this pattern in your own graphs, you don't need to be inside a loop to appreciate it: any workflow with a "do the expensive thing or skip it" decision can use lazy selection to cut wasted compute. Just remember the whole pack is a _testing repo from kijai - the candidate for native ComfyUI loop nodes - so don't build long-lived workflows on these internals. And one gotcha specific to lazy nodes: because the unselected input genuinely doesn't get computed, you can't count on side effects like progress bars firing on the skipped branch. Pick lazy selection for value, not for logging.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | — | |
| value_if_true | * | — | |
| value_if_false | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | * | — |