Nodes/Vsaan212-workflow-utilities/Lazy Switch (Integer)
ComfyUI Node

Lazy Switch (Integer)

Same trick as its float sibling, for whole numbers

By vsaan212·Created 10 months ago·Updated 9 days ago· 1
Lazy Switch (Integer)
    • INT
    compare
    match
    on_true1
    on_false0
    case_sensitivefalse

    Lazy Switch (Integer) is the whole-number member of the pack's switch trio: you hand it a text condition, and it hands back one of two integers depending on whether the condition matched. It exists for the same reason the float and text versions do - in a video workflow driven by a mode string (T2V / I2V / FL2V / R2V), you often need a number that changes with the mode, and you don't want to edit it in four places.

    If you've already read the float version, nothing here will surprise you - it's the same match logic, same lazy evaluation, just with integer values instead of decimal ones. The difference is what you'd feed it: step counts, seed offsets, batch sizes, frame counts, anything that only makes sense as a whole number.

    How it works

    The matching is trimmed and case-insensitive by default, so compare "fl2v " matches match "FL2V". Flip case_sensitive on if you need exact text. And match accepts alternatives separated by commas or pipes - i2v,fl2v matches either mode.

    The "Lazy" in the name is the good part. The node tells ComfyUI which of its inputs it actually needs, and only the winning branch is executed. So if on_true is wired to a node that costs time or VRAM, and the mode comes back as I2V, that upstream node is skipped entirely rather than computed and discarded. On a video graph where the alternative branch might be a full second conditioning pass, that's a real saving.

    The inputs that matter:

    • compare - the upstream text to test (typically a mode string).
    • match - what compare must equal; commas or pipes for alternatives.
    • on_true - the integer when there's a match (default 1).
    • on_false - the integer when there isn't (default 0).
    • case_sensitive - off by default.

    Output is a single INT.

    When to bother

    This is the node for mode-dependent integers: steps at 30 for I2V but 8 for a distilled T2V pass, a different batch size per mode, a seed offset that only applies in reference mode. It's small, it's predictable, and it wires straight into any sampler or loader that takes an INT input.

    Honestly, if you're not running a mode-switching video workflow, this is a solution looking for a problem - a plain PrimitiveInt covers "I need a number" and does it with fewer moving parts. But the moment you've got a selector string driving a graph, the switch turns "remember to change three numbers when I switch modes" into "one dropdown controls everything."

    Installing it

    It's part of vsaan212/Vsaan212-workflow-utilities (MIT). Install via ComfyUI Manager - search Vsaan212-workflow-utilities - or clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vsaan212/Vsaan212-workflow-utilities
    

    Restart ComfyUI; the node lives under vsaan212/utilities. No models, no keys, no extra dependencies for this one. Note the same limitation as its siblings: feed it a bare mode string, not a multi-line tagged blob - if your compare comes from the automation node's tagged output, run it through something that resolves the mode first.

    Categoryvsaan212/utilities

    Inputs (5)

    NameTypeDefaultDescription
    compareSTRINGUpstream text to test (e.g. selector / mode string).
    matchSTRINGWhen compare equals this, output on_true; otherwise on_false. Use commas or pipes for alternatives (e.g. t2v,r2v).
    on_trueINT1-2147483647–2147483647Value when compare matches match.
    on_falseINT0-2147483647–2147483647Value when compare does not match.
    case_sensitiveBOOLEANfalseWhen off, compare and match are trimmed and compared case-insensitively.

    Outputs (1)

    NameTypeDescription
    INTINT