Nodes/Painting Coder Utils/Mask Switch 🔄
ComfyUI Node

Mask Switch 🔄

Flip between two masks with a checkbox instead of a rewire

By jammyfu·Created 2 years ago·Updated about a year ago· 16
Mask Switch 🔄
  • mask_1
  • mask_2
  • mask
use_firsttrue

Comparing masks is a slow way to work when switching means unplugging and re-plugging cables every time. Mask Switch is the two-position toggle for mask inputs: one boolean picks between mask_1 and mask_2, and whatever you chose flows out the other side. No compositing, no thresholding, no surprises - it's a junction, not a processor.

It's one of the four switch nodes in the Painting Coder Utils pack, and it shares their exact design: a use_first boolean plus two optional inputs of the type being switched.

How it works

Checked, use_first passes mask_1; unchecked, mask_2. Both inputs are optional, and the safety net matches the pack's other switches: if you select a path with nothing connected, it returns a blank zero-valued mask (a 1024×1024 all-black mask) instead of throwing. A blank mask is a "mask everything out" in most inpainting contexts, so it's a graceful failure - the graph runs, it just does nothing. If your inpaint suddenly stops changing anything, check whether a switch input came unplugged.

Inputs and output

  • use_first - the boolean selector (default true).
  • mask_1, mask_2 - the two MASK inputs, both optional.
  • Output: mask - whichever mask you selected, ready for an inpaint node, mask combine, or feathered compositing.

Where you'll use it

A/B testing is the obvious case: two segmentation masks, two feathering variants, or a tight mask vs. a loose one, all converging on the same inpaint chain so you can flip and compare. It's also handy as a "test vs. production" gate - a rough hand-drawn mask on one side, a carefully-built ControlNet mask on the other, and the checkbox deciding which one the batch run uses.

If you already run rgthree or a similar pack, its Switch nodes cover masks (and everything else) in one interface and you may not need this - but this is the dependency-light version that does exactly one job.

Install

ComfyUI Manager → Painting Coder Utils, or:

cd ComfyUI/custom_nodes
git clone https://github.com/jammyfu/ComfyUI_PaintingCoderUtils.git

Restart ComfyUI. No models, no keys; the pack's dependencies (numpy, Pillow, torch, gradio) are already present in any working ComfyUI. Inheriting old workflows? v0.3.0 renamed the pack's namespace, which breaks old node references - fix them with the bundled docs/fix/workflow_fixer.html.

Category🎨Painting👓Coder/🔄Switch

Inputs (3)

NameTypeDefaultDescription
use_firstBOOLEANtrue
mask_1optMASK
mask_2optMASK

Outputs (1)

NameTypeDescription
maskMASK