Iter_ConditioningSwitch
Swap positive/negative prompts mid-run with Iter_ConditioningSwitch
- CONDITIONING
A/B testing prompts in ComfyUI usually means duplicating whole sampler chains or hand-editing text between queues. Iter_ConditioningSwitch attacks the problem at the layer that actually matters: the conditioning. It's a typed switch from the ComfyUI-IterSwitch pack that lets you pick between several already-encoded CONDITIONING inputs with a single index - and it's arguably the most practically useful node in the set, because the positive/negative inputs on a KSampler are exactly the thing you most often want to vary.
What it does
You connect several conditioning chains to it - say, prompt A and prompt B, each run through a CLIPTextEncode - and the node passes one through to the sampler. Drive output_index from a counter and one queue run sweeps every variant you built. Need to compare three different negatives against the same positive? Same move on the negative side. It slots into any workflow where "which condition wins" is a question you ask more than once.
Because these are real CONDITIONING objects, not strings, you can also switch between structurally different conditions: a plain positive versus a regional or ControlNet-augmented condition. The switch doesn't care what built the conditioning, only which one you're pointing at.
How it works
The node exposes output_index, input_count, and use_last_input, and its input sockets are generated dynamically: raise input_count and new cond_0, cond_1, … sockets appear via the pack's web extension; lower it and the extras are trimmed without disturbing existing wires.
At run time it computes target = output_index % input_count - out-of-range indexes wrap rather than error - then, with use_last_input on (the default here), it walks backward from your target toward cond_0 looking for the nearest connected input. Disconnect one mid-stack and the run keeps going with the last valid condition below it.
Wiring it up
input_count- how manycond_Nsockets exist. Set this before wiring.output_index- which condition passes through. Wire a counter here to iterate.use_last_input- defaults on; backward-fallback to the nearest connected lower slot.
The single CONDITIONING output feeds the positive or negative input on a KSampler. The classic setup: two CLIPTextEncode chains into one Iter_ConditioningSwitch into KSampler's positive, plus a second one for the negative if you're testing those too.
Installing the pack
ComfyUI-IterSwitch pulls in no extra Python dependencies - there's no requirements.txt and nothing to download. Installation is one clone:
cd ComfyUI/custom_nodes
git clone https://github.com/younger15/ComfyUI-IterSwitch.git
Restart ComfyUI afterward. Or use ComfyUI Manager: search "ComfyUI-IterSwitch," and if the registry doesn't list it, install by Git URL with the same repository link.
Common issues
- Fallback only searches downward.
use_last_inputscans from your target index down tocond_0. If every connected slot sits above your target, the node returnsNoneand the sampler will error out. Keep your fallback slots at low indexes. - Sockets don't show up. The dynamic inputs are JavaScript, so restarting only the backend won't create them - restart ComfyUI fully or refresh the page.
- Index wrap is silent.
output_indexabove the count wraps via modulo instead of warning. Useful for loops, surprising when you miscount.
Fair warning on reputation: this pack has zero community footprint right now - none of the six nodes appear in search data, and there's no crowd wisdom to lean on. The mechanism here is simple and readable in the repo, but if fallback behavior bites, file an issue; you're an early adopter whether you meant to be or not.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| output_index | INT | 00–18446744073709550000 | — |
| input_count | INT | 21–64 | — |
| use_last_input | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CONDITIONING | CONDITIONING | — |