Swap any Two values in a condition
Two values, one boolean, no comparison math
- input_a
- input_b
- input_a
- input_b
The most basic routing primitive in any workflow tool is "swap these two when this flag is on." This node is that, in the leanest form: a boolean invert_values, two wildcard inputs, and two outputs that either pass through or cross over. There's no comparator, no operator dropdown, no arithmetic - just a clean crossbar switch you drive with any BOOLEAN signal.
Why you'd reach for it: you've got two branches in a workflow - two models, two prompts, two latent paths - and you want them to trade places based on a condition that's already a boolean somewhere. Maybe HasInputvalue told you a branch is live, or a seed check produced a boolean, or you just want to flip two values by hand with a checkbox. When the condition is a boolean, this is the honest minimal tool, and it avoids dragging in a full comparator node just to do a swap.
How it works
It's two outputs and one decision:
invert_values = True→ outputinput_acarries input_b's value, outputinput_bcarries input_a's value (swapped).invert_values = False→ straight pass-through, original order.
Both inputs are wildcard-typed, so it works on any type - images, strings, numbers, conditioning. There's an IS_CHANGED hook that keys off the input values, so it re-evaluates correctly when either input changes rather than serving a stale swap.
The one thing that reads oddly on first sight: the toggle defaults to True, meaning it swaps by default. That's a deliberate "invert" framing - the author named the flag for what it does (invert the order), not for the resting state. If you wire it up and your values come out crossed when you expected straight, this is why.
The inputs that matter
invert_values- the boolean that flips the swap. DefaultTrue.input_a/input_b- the values to route, any type.
Outputs: input_a and input_b, straight or swapped.
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
Beyond the default-True surprise, the main trap is expecting a conditional to be attached. There isn't one - this node doesn't compare anything. The boolean has to come from somewhere: wire a comparator node's output into invert_values, or a HasInputvalue, or just the checkbox. If you need the comparison built in (like "swap when a > b"), you want this pack's SwapAnyComparison instead, which fuses the comparator into the swap. The division of labor is clear: SwapAnyCondition is the dumb crossbar, SwapAnyComparison is the crossbar with a brain attached.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| invert_values | BOOLEAN | true | When True, swaps input_a and input_b positions in output. When False, returns inputs in original order |
| input_aopt | * | First input value. Will be returned as 'input_b' if invert_values is True, otherwise as 'input_a' | |
| input_bopt | * | Second input value. Will be returned as 'input_a' if invert_values is True, otherwise as 'input_b' |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| input_a | * | — |
| input_b | * | — |