Nodes/PG Nodes/Xor Toggle
ComfyUI Node

Xor Toggle

One Checkbox, Two Opposite Booleans

By GizmoR13·Created 11 months ago·Updated 11 months ago· 16
Xor Toggle
    • boolean 1
    • boolean 2
    toggletrue

    Some decisions in a workflow are binary and exclusive: run branch A or branch B, never both. Xor Toggle (class PgXorDualToggle) is a single checkbox that emits two booleans in permanent opposition - flip it one way and output 1 goes true while output 2 goes false; flip it back and they trade places. It's from PG Nodes, Piotr Gredka's (GizmoR13) small MIT-licensed utility pack, in the same family as the pack's Checkpoint Switch: a readability play for graphs that keep asking you the same yes/no question.

    What it actually does

    The input is toggle, a BOOLEAN that defaults to true and renders as a checkbox right on the node. The outputs are boolean 1 and boolean 2, and they're always inverted:

    toggle = true  → boolean 1 = true,  boolean 2 = false
    toggle = false → boolean 1 = false, boolean 2 = true
    

    The interesting bit is under the hood. ComfyUI caches node results and skips re-running a branch when nothing about its inputs changed, and a plain boolean flip often isn't enough to invalidate that cache. This node defines IS_CHANGED to return the current toggle state, so flipping the box forces everything downstream to actually recompute. Without that hook, you'd flip your switch and watch the graph shrug.

    What to use it for

    Anywhere you have two mutually exclusive settings driven by one decision. A common pattern: the on/off of image saving in one branch versus another, or feeding the exclusive inputs of a switch node so only one side is active. You could also wire another node's boolean output into toggle to make the decision automatic rather than manual - the checkbox isn't the only way in.

    It's worth being honest about how thin this is: if you already run rgthree or ComfyUI's built-in Boolean nodes, you can assemble the same logic with a couple of Not nodes. The value is ergonomic, not functional - one named, clickable box that reads exactly as what it does, in a pack whose whole philosophy is "stop hunting for scattered knobs." You'll appreciate it in a saved workflow you revisit, not build fresh every day.

    Installing it

    No dependencies beyond ComfyUI itself; the whole pack is pure Python.

    ComfyUI Manager → search "PG Nodes" → Install → Restart
    

    Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GizmoR13/PG-Nodes
    # restart, then search "Xor Toggle" under PG/Utils
    

    Where people get burned

    Keep scope in mind: this node moves booleans and nothing else. If you're trying to switch between two model checkpoints or latent paths, that's the pack's PgCpSwitch, not this node - wiring a boolean into a MODEL port gets you a confusing error, not a toggle. And if flipping the box seems to do nothing, check that the nodes downstream actually consume a boolean input - many loaders have their toggles set to forceInput, meaning a plain checkbox won't feed them at all. Feed the toggle output into a node that genuinely accepts a boolean wire, and it behaves.

    CategoryPG/Utils

    Inputs (1)

    NameTypeDefaultDescription
    toggleBOOLEANtrue

    Outputs (2)

    NameTypeDescription
    boolean 1BOOLEAN
    boolean 2BOOLEAN