Nodes/Crystools/πŸͺ› Switch mask
ComfyUI Node Runs on cloud

πŸͺ› Switch mask

Flip between two MASK inputs with one boolean

By crystianΒ·Created 3 years agoΒ·Updated 9 months agoΒ· 1,940
πŸͺ› Switch mask
  • on_true
  • on_false
  • mask
β—„booleantrueβ–Ί

Same idea as Switch latent, just for masks: two MASK inputs, one boolean, one output. Useful anywhere you're building a workflow where the mask itself is conditional - say, a manually-painted mask for one pass and an auto-generated segmentation mask for another, and you want to flip between them without rewiring your inpainting or compositing chain every time.

It's part of the small family of typed switches this pack ships alongside the generic Switch from any - Crystools favors a dedicated node per type (latent, mask, and whatever else the README's Switch section documents) over one universal switch, which means ComfyUI's type checker catches a wrong connection at build time instead of at execution. That's the trade-off versus Switch from any: this one only ever accepts masks in either slot, so plugging in the wrong type gets rejected immediately when you try to draw the link, rather than surfacing three nodes downstream as a cryptic shape error.

How it works

No processing happens to the mask itself - it just holds two MASK inputs and passes through whichever one the boolean currently selects.

The inputs and outputs that matter

  • on_true / on_false - both required MASK inputs, your two candidate masks.
  • boolean - defaults to true, meaning on_true passes through out of the box. Flip it for on_false.
  • Output: mask - whichever one won, ready to feed into a Set Latent Noise Mask, a compositing node, or wherever your mask normally goes.

How to install it

Through ComfyUI Manager: search crystools, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/crystian/comfyui-crystools.git
cd comfyui-crystools
pip install -r requirements.txt

You'll find it under crystools πŸͺ› / Switch. No models, no GPU dependency for this node.

Common issues & troubleshooting

Like its LATENT sibling, both on_true and on_false are required - ComfyUI won't queue the graph with either socket left unconnected, so if you're only planning to use one mask source for now, you still need something plugged into the other, even if it's just a blank mask.

The useful thing to know is that Crystools' switches aren't naive pass-throughs at the execution level: the pack added "lazy switches" in version 1.24.0, using ComfyUI's lazy-evaluation support so only the branch the boolean actually selects gets computed. That matters if generating one of your two masks is itself expensive - an auto-segmentation pass, say - because it means the switch genuinely skips that work when it isn't the active branch, rather than computing both masks and quietly discarding one. Beyond that, the usual masking gotchas apply once the value comes out the other side: make sure whatever's feeding on_true and on_false is actually shaped like the image it's meant to mask, since a mismatched resolution will surface as an error downstream rather than at this node.

Categorycrystools πŸͺ›/Switch

Inputs (3)

NameTypeDefaultDescription
on_trueMASKβ€”
on_falseMASKβ€”
booleanBOOLEANtrueβ€”

Outputs (1)

NameTypeDescription
maskMASKβ€”