Nodes/ComfyUI-JNK-Tiny-Nodes/Switch Integer JNK
ComfyUI Node

Switch Integer JNK

Turn an ON/OFF toggle into a 1 or a 0

By AljnkΒ·Created about a year agoΒ·Updated 12 months agoΒ· 3
Switch Integer JNK
    • int
    β—„stateONβ–Ί

    Sometimes a workflow needs a switch you can multiply by. ComfyUI's conditional logic mostly wants numbers - denoise strengths, weights, counts - and a boolean toggle doesn't multiply with anything. "Switch Integer JNK" is the adapter: one ON/OFF dropdown, one output, and it emits 1 when ON and 0 when OFF. The pack's README calls it exactly what it is: "Convert ON/OFF states to 1/0 integers for conditional logic."

    The use case is multiplying things on and off. Wire the int output into a multiplier node and you've got a master switch for an entire branch - multiply a denoise value by it and the branch runs at full strength or zero, controlled by a labeled toggle instead of an awkwardly-scaled slider. Feed it into a step or offset node and you've got a counter that advances conditionally. It's the "logic glue" category of node: nothing glamorous, but every serious workflow ends up with two or three of them lying around.

    The mechanism is deliberately dumb. state is a dropdown (ON/OFF, default ON), and the function is literally return 1 if state == "ON" else 0. There's no state, no caching, no IS_CHANGED games - it evaluates fresh on every run, so flipping the toggle takes effect on the next execution. The single output is int, which plugs into any INT input.

    The reason it exists as its own node instead of a stock primitive is ergonomics, not capability. You could hand-type an INT primitive and change it between runs, but a labeled dropdown is visible, self-documenting, and hard to fat-finger into the wrong value. In a shared or revisited workflow, "Switch Integer" reads instantly where "INT 0" doesn't.

    Install: ComfyUI Manager β†’ search "JNK" β†’ Install, then restart. Or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/Aljnk/ComfyUI-JNK-Tiny-Nodes.git
    

    Then restart. No dependencies beyond ComfyUI itself - this is a couple of lines of Python.

    Gotchas: it never outputs anything except 1 or 0, so don't build logic that expects a value "between." And it's not a true conditional - it can't branch or route, it just emits a number; the branching happens downstream in whatever consumes the INT. The one real confusion is the sibling "Switch Index JNK," which outputs 2/1 instead of 1/0 for the index-convention world. If your numbers come out swapped or one-off, you grabbed the wrong sibling. Otherwise this is as close to a foolproof node as this pack ships.

    CategoryπŸ”§ JNK

    Inputs (1)

    NameTypeDefaultDescription
    stateCOMBOON2 options: ON, OFF

    Outputs (1)

    NameTypeDescription
    intINTβ€”