ComfyUI Node

Mask Switch

Pick between four masks with a single integer

By rookiepsi·Created about a year ago·Updated 11 months ago· 9
Mask Switch
  • mask_1
  • mask_2
  • mask_3
  • mask_4
  • MASK
switch1

Masked workflows have a nasty habit of needing "sometimes this mask, sometimes that one." Inpainting a face with one mask, outpainting with another, then deciding which based on a test - the manual approach is deleting and reconnecting wires. Mask Switch from ComfyUI Extended does it with one integer: switch set to 1, 2, 3, or 4, and the matching mask comes out the MASK socket.

It's from the switch section of the pack (alongside an image switch you'll find in the same menu) and it's exactly as simple as it sounds. That's the appeal.

How it works

Required input switch (INT, 1–4, default 1). Optional inputs mask_1 through mask_4 (MASK). One MASK output. The implementation is a four-way if - no fading, no blending, no interpolation. Whatever mask corresponds to the current switch value is passed through, untouched.

The input sockets are optional, which is a small mercy: you can wire up only the masks you actually use and leave the rest dangling.

Install

cd /path/to/your/ComfyUI/custom_nodes
git clone https://github.com/rookiepsi/comfyui-extended.git

Restart ComfyUI; it's under comfyui-extended/switch. Or via ComfyUI Manager: search "ComfyUI Extended", install, restart. The pack has zero dependencies and downloads nothing.

Common issues

  • Unconnected masks return nothing. If you set switch to 3 but never connected mask_3, the node has nothing to hand back and the run fails downstream. Wire what you select.
  • It doesn't know about batches. This is a plain pass-through selector - if your masks are batched (multiple images), the switch treats the whole batch as one unit and passes it through intact, which is usually what you want anyway.
  • No "auto" mode. The switch value is whatever you feed it. To make it automatic, feed the switch from a computed integer - the pack's Utility Expression doing 1 if a > b else 2 plugs right in.

Where it fits: any workflow where you're A/B testing masks or toggling between inpaint regions. It's not glamorous, but it's the difference between a two-minute graph edit and a one-click toggle.

Categorycomfyui-extended/switch

Inputs (5)

NameTypeDefaultDescription
switchINT11–4
mask_1optMASK
mask_2optMASK
mask_3optMASK
mask_4optMASK

Outputs (1)

NameTypeDescription
MASKMASK