ComfyUI Node

XOR

True when an odd number of inputs are true

By silveroxides·Created 7 months ago·Updated 3 months ago· 3
XOR
  • inputs
  • BOOLEAN

XOR is the logic node with the least obvious name and the most satisfying behavior once you get it. With exactly two inputs it's "true when the inputs differ" - one true, one false → true; both same → false. The pack's implementation extends that naturally to two to ten inputs: true when an odd number of inputs are true. That's the whole rule, and it's worth internalizing because it unlocks "either, but not both" logic that plain OR can't express.

Where does that matter in a workflow? The flagship use is toggle/alternation. If you have two mutually exclusive modes, XOR between two flags says "exactly one of them is set" - the shape of a radio-button choice. It's also the classic change-detector: compare a condition against its previous state and XOR fires exactly when it flipped. In batch and scheduling work, an odd-count XOR over a row of per-item flags gives you "this batch is in the A phase" style alternation. If you've ever built "either A or B, but not both, and not neither," you were building XOR by hand.

How it works

inputs is an autogrowing list - two to ten booleans, added with the plus button. On execution the node folds the values with "not-equal" (Python's != on booleans), which is exactly how XOR is defined for two values, and the fold generalizes to odd-count-true across more. The output is a single BOOLEAN.

A useful mental model: for any number of inputs, XOR answers "did an odd number of you say true?" Two inputs → true when they differ. Three inputs → true when one or three of them are true, false when zero or two are. It's deterministic and stateless like everything else in the pack, so it's safe mid-graph.

One practical note: XOR over more than two inputs is a niche ask, and if you're doing it, double-check the semantics you actually want - "exactly one true" and "odd number true" diverge once you pass two inputs. This node implements the latter (the standard mathematical XOR).

The inputs that matter

  • inputs (2–10): the booleans to XOR together.

Output is a single BOOLEAN.

Install

This node ships in the ComfyUI-LogicMath pack. Install via ComfyUI Manager (search "ComfyUI-LogicMath", Install, restart) or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-LogicMath

No pip dependencies, no model downloads. The pack targets ComfyUI's newer extension API, so update ComfyUI if the node doesn't appear after a restart.

Common issues

  • "It's true when I expected false" - count your true inputs. With three inputs, two true = false under XOR (even count), which surprises people who came from "inputs differ."
  • Type errors - feed it real booleans; like the rest of the logic nodes it doesn't coerce numbers.

XOR is the logic node you'll use rarely and love specifically. For "either but not both," there's no cleaner one-node answer in the pack.

Categoryutils/logic

Inputs (1)

NameTypeDefaultDescription
inputsCOMFY_AUTOGROW_V3

Outputs (1)

NameTypeDescription
BOOLEANBOOLEAN