ComfyUI Node

Switch Int

Pick between two step counts without rebuilding the graph

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
Switch Int
    • INT
    conditionfalse
    if_true0
    if_false0

    Switch Int is the integer-specialist version of the pack's Switch Any, and it's one of those nodes you'll find buried in almost every workflow you download once you know to look. A boolean condition decides between two integers, if_true and if_false, and whichever one wins flows out the single output. That's it - and for a graph tool with no if statement, that's a superpower.

    Why you'd reach for it

    Integer parameters are everywhere in ComfyUI - steps, batch size, seed, width, height, tile counts - and the switch is how one condition routes between two of them. The setup I keep coming back to: a checkbox for "quick preview" vs "final quality," where a single boolean picks between 12 steps and 30 steps feeding the same KSampler. Same graph, two completely different generation budgets. Or a Compare node upstream decides "batch is too big" and the switch drops the batch size for the next pass.

    Because the condition can be any boolean - a checkbox, a Compare result, a logic gate, a Number → Bool conversion - you can chain these into workflows that make real decisions on their own. "If the image is under 1024 wide, use the smaller batch and fewer steps" is a one-boolean pipeline away from running itself.

    How it works

    Exactly what it looks like: if_true if condition else if_false, with strict INT sockets on both candidate inputs and the output. The author's description: "Returns if_true when condition is True, otherwise returns if_false. Works with integers." It lives in SimpleLogics/Switch with the float, string, and any-type variants.

    The inputs that matter

    Three required inputs:

    • condition - the BOOLEAN that picks the branch (defaults to False)
    • if_true - the INT returned when condition is true (default 0)
    • if_false - the INT returned when condition is false (default 0)

    One INT output, ready to feed a KSampler's steps, a batch size, or any integer socket.

    Installing it

    Part of danipisca07/ComfyUI-SimpleLogics, the dependency-free pure-Python pack - no requirements.txt, no model downloads. Install from ComfyUI Manager (search "SimpleLogics") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/danipisca07/ComfyUI-SimpleLogics
    

    Restart ComfyUI and you're set.

    Common issues

    The footgun here is the strict typing working too well: because the sockets are INT, wiring in a float forces an auto-conversion, and truncation can make your "30.0 steps" silently become "30" - or worse. If you're switching values that can legitimately be fractional, that's Switch Float's job. Otherwise there's nothing to break: it's a pure selector with no hidden state. One tip - if the branch you expected never fires, trace the boolean, not the switch; a silently-inverted condition (say, a NOT you forgot about) is the usual culprit. (Usual pack quirk: installing SimpleLogics also registers an unrelated GeoCalib camera node - ignore it.)

    CategorySimpleLogics/Switch

    Inputs (3)

    NameTypeDefaultDescription
    conditionBOOLEANfalse
    if_trueINT0
    if_falseINT0

    Outputs (1)

    NameTypeDescription
    INTINT