Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Toggle to Integer
ComfyUI Node

EmAySee Toggle to Integer

One checkbox, two integers — a boolean-to-int switch for conditional values

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Toggle to Integer
    • TOGGLE_INT_OUTPUT
    toggle_inputfalse
    int_if_on1
    int_if_off0

    The smallest useful idea in this pack: a checkbox, two integer fields, one integer out. Toggle on → output int_if_on. Toggle off → output int_if_off. That's the whole node, and it exists because ComfyUI is full of places where you need a number that flips between two values, and wiring a boolean into an INT socket doesn't work - the types don't match.

    Reach for it any time you'd otherwise do "if X, use 4, else use 2" in your head. Classic examples: a CFG scale that steps up for a detail pass, a seed that switches between "keep fixed" and "new each time" (1 vs -1), a steps value that differs between preview and final render, a batch size that's 1 for testing and 4 for real runs. Flip the checkbox, and the downstream value changes without editing a bunch of nodes.

    How it works

    The mechanism is a two-branch return:

    if toggle_input:
        return (int_if_on,)
    else:
        return (int_if_off,)
    

    No state, no side effects, nothing clever. int_if_on defaults to 1, int_if_off defaults to 0, so out of the box it behaves like a boolean cast to integer - which is honestly a fine default if that's all you need.

    Inputs and output

    • toggle_input (BOOLEAN, default false) - the checkbox. You can also wire a boolean from another node into it, which is where this gets useful: a logic node upstream can flip the output automatically.
    • int_if_on (INT, default 1) - the value when the toggle is true.
    • int_if_off (INT, default 0) - the value when false.

    The single output, TOGGLE_INT_OUTPUT, feeds any INT input - samplers, loaders, math nodes, switch indices, you name it.

    Installing it

    Same pack as the rest: ComfyUI_EmAySee_CustomNodes via ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
    

    Restart. It shows up under EmAySee_Utils. No dependencies, no models.

    The honest take

    There are fancier switch nodes out there - ones that take multiple values, or compare at runtime, or come with a dropdown. This one is the 80/20 version: it handles the two-value case with the least ceremony, and since the pack auto-loads all its nodes anyway, it's already sitting in your menu. The one thing to watch is wiring a live boolean into the toggle: if an upstream node flips it mid-batch (say, from a randomizer), the output flips with it, which is either exactly what you wanted or a sneaky source of nondeterminism - keep the checkbox manual if you want runs to stay comparable. Otherwise, it's boring in the best way: it does one thing, visibly, and gets out of your way.

    CategoryEmAySee_Utils

    Inputs (3)

    NameTypeDefaultDescription
    toggle_inputBOOLEANfalse
    int_if_onINT1
    int_if_offINT0

    Outputs (1)

    NameTypeDescription
    TOGGLE_INT_OUTPUTINT