Integer Switch
One boolean, two numbers, zero rewiring
- INT
ComfyUI has no if/else. You cannot branch. What you can do is compute both of your options and pick one at the last second, and that is the entire job of Integer Switch: a toggle, two number boxes, one INT out the other side.
What you'd reach for it for
The reason that's more useful than it sounds is that it lets one workflow hold two configurations. Draft steps vs final steps. One image vs four in the batch. 832×1216 for the SDXL leg and 1024×1024 for the Flux leg. Without a switch that's two graphs, or one graph you rewire by hand every time you change modes. With this node you flip a toggle, nothing else on the canvas moves, and the nodes downstream can't tell anything happened.
It's plumbing, in the good sense: a node that touches no pixels and exists to fight the other problem in ComfyUI, which is that a graph you can't read is a graph you can't debug. "Which of these two values is live right now" is a question a switch answers at a glance.
How it works
This is the rare node where you can read the whole implementation in one breath:
def select_int(self, switch, true_switch_int, falce_switch_int):
chosen = true_switch_int if switch else falce_switch_int
return (int(chosen),)
That's it. No dependencies, no state, nothing that can fail at runtime. First number when the toggle is on, second number when it's off. Both values live in the node permanently; the switch doesn't compute anything, it just selects.
The inputs that matter, and the output
Three inputs, one output, straight from the node's schema:
- switch - boolean, on by default. On means
true_switch_intwins. - true_switch_int - default 1.
- falce_switch_int - default 0. Yes, that spelling is real. It's in the code and it's the name the socket carries, so use it exactly as written if you ever edit the workflow JSON by hand or generate prompts programmatically. In the UI it's just a number box, so most people never notice.
- INT - the selected integer, and the only output. Wire it into anything typed INT: steps, batch size, width, height, seed, tile count, latent count.
The interesting move is driving the toggle from the graph instead of your mouse. Right-click the switch and convert the widget to an input - ComfyUI allows that on a toggle, same maneuver as converting a KSampler seed - then wire a boolean into it. From inside this pack, the natural partner is MetaData Check Key & Value, which outputs an exists boolean. Tag a run with metadata, test for a tag, and let the answer flip a number. That pairing is what both nodes exist for.
Installing it
The whole pack is one install. In ComfyUI Manager, search its registry title, ComfyUI-MDSNodes, and hit install - or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/MarwanDSAI/comfyui-mdsnodes
Restart ComfyUI and the node shows up under MDSNodes/logic. There is nothing to download and nothing to pip install: the README's "no extra packages required" claim checks out against the shipped requirements.txt, which is empty. The catch is documentation - the README's node list stops at v1.1.0 and doesn't mention Integer Switch at all, so the source (a twenty-line file) is your manual. It's a small single-author pack built to support one Civitai article's model-testing workflow, with essentially no discussion of it in the usual places, so read the code rather than trusting the write-up.
Where people trip
- It's an INT socket, and there's no float twin. If you wanted to flip CFG between 7 and 1, this isn't the node - nothing in this pack switches floats.
- One switch flips one number. If you need model and steps and CFG to move together, you're stacking switches and keeping them in sync by hand, which is exactly the stale-value bug that node-based config busses were invented to prevent. Past two or three values, use a context node (rgthree's Context, or a pipe-style pack) instead.
- Manual vs automatic. This is an A/B selector: you choose. rgthree's
Any Switchis the other shape - no selector, it passes the first input that isn't empty. Different tool; don't reach for this one expecting the graph to decide for you. - If a
control_after_generatedropdown appears next to the two integer fields (ComfyUI attaches it to integer widgets), leave it onfixed. A self-incrementing "on" value that quietly changes between runs is a nasty way to lose an afternoon. - Both numbers live in the node. Saved workflow, saved values - good for reproducibility, mildly confusing the first time you open someone else's graph and find their switch on 8 steps for a reason you can't see.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| switch | BOOLEAN | true | True outputs the First Int, False outputs the Second Int. |
| true_switch_int | INT | 1-18446744073709550000–18446744073709550000 | Value returned when the switch is True. |
| falce_switch_int | INT | 0-18446744073709550000–18446744073709550000 | Value returned when the switch is False. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | The selected integer. |