Nodes/ComfyUI_MqUtils/MQ Int Switch
ComfyUI Node

MQ Int Switch

The boring if/else for numbers you'll actually wire up

By mikeshuangyan·Created about a year ago·Updated about a year ago· 1
MQ Int Switch
    • VALUE
    if_true0
    if_false0
    conditiontrue

    ComfyUI doesn't give you an if/else statement. You can chain nodes into one, sure, but the community's favorite workaround - those "Anything Anywhere" routers that let any output feed any input - has a well-earned reputation for making workflows impossible to debug. MQ Int Switch is the boring, type-safe alternative for the one case that comes up constantly: pick between two integer values based on a boolean.

    The whole job fits in a sentence: if the condition is true, output if_true; otherwise output if_false. Nothing is converted, nothing is inferred, and it can't accidentally feed you a string when you asked for an int. That last part is the selling point. In an ecosystem where over-eager Any-routing turns a typo into a session of hunting through 80 nodes, a switch that only ever touches INTs is a feature.

    When would you actually use it? The canonical case is seeds. Lock-seed discipline is the community's number-one debugging habit - change one variable at a time, compare, change the next - and a switch is how you flip that variable at runtime without touching a widget mid-run. Swap between two hand-picked seeds to A/B a prompt, toggle a steps value between 20 and 40, flip batch size for a quick memory test, or switch CFG between 3.5 and 7 when a condition downstream says so.

    Inputs, all three of which you'll touch:

    • if_true (INT, default 0) - returned when the condition is true
    • if_false (INT, default 0) - returned when the condition is false
    • condition (BOOLEAN, default true) - the thing that picks

    The output is a single INT, VALUE. Feed it into a seed widget, a sampler's steps, a batch size - anywhere an int wire goes.

    Two gotchas worth knowing before they eat your afternoon. First, the condition defaults to true, so a freshly placed node returns if_true until you do something about it. Wire a boolean in or click the toggle; a surprising number of people connect everything, run, and assume it's broken because they never noticed the checkbox was already on. Second, this node is ints only, on purpose. If you need to switch floats, strings, or entire conditioning pipelines, you want a general-purpose switch - rgthree's Any or Context Switch, or WAS, are the usual suspects. The trade-off is that the general ones will cheerfully route almost anything, and that's exactly when the debugging pain starts.

    Install: ComfyUI Manager, search ComfyUI MqUtils, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mikeshuangyan/ComfyUI_MqUtils.git
    

    No dependencies beyond what ComfyUI already has, no models to download. It's a four-line node in a small pack nobody on reddit talks about, which for a utility this simple is fine - it's not supposed to be interesting, it's supposed to be predictable.

    Reach for it whenever you catch yourself about to duplicate a whole workflow just to test a different number. That's the moment this node exists for.

    CategoryMQ Utils/Utils

    Inputs (3)

    NameTypeDefaultDescription
    if_trueINT0
    if_falseINT0
    conditionBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    VALUEINT