Mask Switch (JPS)
Pick one of five masks with an integer, no rewiring
- mask_1
- mask_2
- mask_3
- mask_4
- mask_5
- mask_out
Mask Switch (JPS) is a "5-to-1" router: feed it up to five masks, dial in a number, and only the mask at that number gets passed downstream. It's plumbing, not generation - nothing here creates or edits a mask, it just decides which one your graph actually uses.
Where this earns its keep is any workflow where you generate or prepare more than one candidate mask and want to switch between them without physically rewiring your canvas every time. Say you've got a SAM mask, a color-range mask, and a hand-painted mask all sitting in the same graph - instead of disconnecting and reconnecting wires to test each one, you wire all three into a Mask Switch and flip one integer widget. It's also the standard trick for conditional branches: run different inpaint regions depending on which pass you're on, or A/B a masking method against another without maintaining two separate workflows.
How it works
The mechanism is deliberately dumb, which is the point. select is an integer - 1 through 5 - and whichever mask_N input matches that number becomes mask_out. That's it. There's no "pick the first non-empty one" fallback like some switch nodes do; you tell it exactly which slot to use, and it uses that slot. That predictability cuts both ways: you always get exactly the behavior you dialed in, but if you rewire your graph and forget to update select, it'll keep quietly outputting whatever used to be at that index instead of complaining.
The inputs and outputs that matter
select(INT, required) - which slot to output. This is the only thing you actually set.mask_1throughmask_5(MASK, optional) - your candidate masks. You don't need all five wired; only fill in the ones you're actually switching between.mask_out(MASK) - the chosen mask, ready to feed into whatever consumes it downstream (aSetLatentNoiseMask, an inpainting sampler, a compositing node).
The pack ships a whole family of these - Integer Switch, Image Switch, Latent Switch, Conditioning Switch, Model Switch, VAE Switch, ControlNet Switch - all sharing this exact select-by-index pattern. Once you know how one works, you know how they all work.
How to install it
Easiest path is ComfyUI Manager: search for "JPS Custom Nodes for ComfyUI" and install. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/JPS-GER/ComfyUI_JPS-Nodes.git
Restart ComfyUI. There's nothing to download beyond the node code itself - no models, no heavy Python dependencies. This whole pack is glue and math nodes, so install friction is about as low as it gets.
Common issues & troubleshooting
Upgrading from an old copy of the pack. The README is explicit about this: if you already have a previous version of "JPS Custom Nodes for ComfyUI" installed, delete it before pulling the new one. Leaving both around means two folders registering nodes with the same class names, which is a classic source of duplicate-node errors and unpredictable behavior in ComfyUI's custom node loading - not specific to this node, but it'll hit Mask Switch same as everything else in the pack.
select points at an empty slot. If you dial in an index that has nothing wired to it, you're asking the node to output a mask that doesn't exist. Double-check that whichever number you set actually has something connected before you assume the node is broken.
The output looks stale. This is the tradeoff of explicit-index switching mentioned above - if you add or remove a mask input and don't update select to match, you'll keep getting the old choice. Get in the habit of checking the widget value any time you touch the wiring around this node.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| select | INT | — | |
| mask_1opt | MASK | — | |
| mask_2opt | MASK | — | |
| mask_3opt | MASK | — | |
| mask_4opt | MASK | — | |
| mask_5opt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask_out | MASK | — |