XOR
True when an odd number of inputs are true
- inputs
- BOOLEAN
XOR is the logic gate that everyone learns in school and almost nobody uses - until they need it. UC_LogicXOR returns true when an odd number of connected inputs are true. With two inputs that's the classic exclusive-or: true when exactly one is on. With three or more, it generalizes: 1 true → true, 2 true → false, 3 true → true. That "odd count" behavior is genuinely useful for toggles and flip-flops.
Two practical jobs it's great at. First, a state toggle: connect a "current state" boolean and a "flip it" boolean, and XOR gives you the new state - flip on → state inverts, flip off → state stays. That's a real pattern for iterative or batched workflows. Second, a consistency check: if you have several conditions that should agree (say, two model-loading checks), a two-input XOR being true tells you they disagree, which is itself a useful signal for debugging or gating.
How it works
It evaluates each connected boolean and sums the truthy count, returning true when that count is odd - the source is literally sum(bool(v) for v in values) % 2 == 1. The autogrowing inputs (COMFY_AUTOGROW_V3) behave like the rest of the pack's logic family, so you add sockets freely.
One input group (inputs), one BOOLEAN output.
Where the pack fits
XOR is the third of the pack's autogrow logic family alongside UC_LogicAND and UC_LogicOR, plus the non-autogrow NOT and the any-type IF. This pack's logic nodes explicitly replace the ones from the old ComfyUI-LogicMath collection, and the README is clear: uninstall the standalone pack before accepting ComfyUI's workflow-replacement prompt, or you'll get duplicate/conflicting node registrations.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart (or ComfyUI Manager → search "ComfyUI-UtilsCollection"). Deps: opencv-python, typing-extensions.
Honest note: most workflows never need XOR, and if you're not already picturing the toggle pattern above, AND/OR + IF will cover you. But the toggle use case is the sleeper hit - once you've built a stateful loop in ComfyUI, you'll be glad the pack ships it rather than making you hand-roll the parity math.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| inputs | COMFY_AUTOGROW_V3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |