Nodes/ComfyUI Layer Style/LayerUtility: Switch Case
ComfyUI Node Runs on cloud

LayerUtility: Switch Case

Switch Case

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerUtility: Switch Case
  • input_default
  • input_1
  • input_2
  • input_3
  • ?
â—„switch_conditionâ–º
â—„case_1â–º
â—„case_2â–º
â—„case_3â–º

This is a router. It's the ComfyUI version of a switch/case statement from programming: you give it a text condition, it compares that against a few labels, and it passes through whichever input matches - falling back to a default if nothing does. In a graph where everything is wired statically, this is how you get a branch: one string flips which of several inputs flows downstream, without you rewiring by hand.

The mechanic is exactly the classic switch/case. switch_condition is the string you're testing. case_1, case_2, and case_3 are the labels to match it against. input_1, input_2, and input_3 are the corresponding values (all typed *, so they can be anything - an image, a mask, a model, a string, a number, a latent). And input_default is the fallback. At runtime the node checks: does switch_condition equal case_1? Pass input_1. Equal case_2? Pass input_2. case_3? input_3. No match? Pass input_default. The single output - labeled ? because its type depends entirely on what you wired in - carries whichever input won.

Where this earns its place is parameterized or reusable workflows. Say you have one graph that should behave differently for "portrait" versus "landscape" versus "product": set those as the three cases, wire the appropriate settings/models to each input, and drive switch_condition from a primitive or an upstream node. Change one string and the whole downstream path switches. It's also handy for A/B testing two pipelines through the same tail end, or for building a template you hand to someone who only needs to type a mode name.

Because the inputs are *-typed, it's genuinely universal - the same node routes conditioning, images, or model patches. That flexibility is the appeal and also the thing to be disciplined about: whatever you wire into the inputs and wherever the output goes must actually be compatible types, or you'll get a mismatch error downstream when a branch you didn't test finally fires.

Install is the pack standard: search "ComfyUI Layer Style" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt and restart. No models - it's pure logic and loads instantly.

The gotcha is that the match is a literal string comparison, so Portrait and portrait are different, and a stray space in a case label will silently drop you to the default. If your switch always seems to fall through to input_default, check that switch_condition matches a case exactly, character for character. And the standing LayerStyle warning: even a trivial logic node like this won't appear if the pack failed to import - the pack's signature dependency-conflict failure takes every node down with it - so if it's missing, check the console, run "Try Fix" in Manager, and reinstall the requirements.

Category😺dzNodes/LayerUtility/Data

Inputs (8)

NameTypeDefaultDescription
switch_conditionSTRING—
case_1STRING—
case_2STRING—
case_3STRING—
input_default*—
input_1opt*—
input_2opt*—
input_3opt*—

Outputs (1)

NameTypeDescription
?*—