Nodes/ComfyUI Prepack/đź’€Prepack Logic String
ComfyUI Node

đź’€Prepack Logic String

A contains-check that routes your workflow — string matching without regex hell

By S4MUEL-404·Created 12 months ago·Updated 10 months ago· 2
đź’€Prepack Logic String
  • true
  • false
  • any
  • output
â—„target_stringâ–ş
â—„stringâ–ş
â—„any_target_nameâ–ş
â—„any_nameâ–ş

The most common string operation in a ComfyUI workflow is "does this text contain that text?" - does the loaded filename mention "anime", does this prompt contain the word "landscape", is this trigger tag present. Doing that in vanilla ComfyUI means a regex node, which is overkill for a contains-check and a whole learning curve if you don't know regex. The đź’€Prepack Logic String is the no-regex version: set a target_string, feed it the text to test via string, and route one input or another based on whether the target appears.

It's the string-flavored sibling of đź’€Prepack Logic Int, and it's the more useful one for most people, because in practice a huge fraction of workflow branching is driven by text - filenames, tags, prompt fragments - not numbers.

How it works

The logic is a case-insensitive contains test. target_string is what you're looking for; string is the text being searched. If target_string is found inside string (both trimmed, case folded), the node outputs whatever is on true; otherwise it outputs false. The output is typed *, so you can route any kind of value - a conditioning, a model, a string, a latent.

Same escape hatch as the int version: an any input plus any_target_name and any_name fields. If any_target_name appears as a substring of any_name, the any input is returned immediately, before the main contains-check runs. So you can hard-route by an override name without touching the primary logic.

The inputs that matter:

  • target_string - what to look for.
  • string - the text to search. Optional; if it's missing, the node falls back to the any/false path.
  • true / false - the two values to route.
  • any, any_target_name, any_name - the override.

A practical shape: a checkpoint loader that outputs a model-name string into string, target_string = "anime", true wired to an anime-tuned CLIP encode path, false to the photoreal path. One node, and the branch is self-explanatory when you read the workflow later.

Where people get burned

It's a contains check, not equality. target_string = "an" matches "anime", "landscape", and "bank" alike. If you want exact matches you'd need a different tool - this node deliberately does substring matching.

And again, the empty-string case: with target_string empty, the contains test is effectively skipped, and the node routes via the any override or to false. If your branches stop switching, check that target_string is actually populated - a blank target is a silent way to break the routing.

Installing it

It ships in the Prepack pack:

cd ComfyUI/custom_nodes
git clone https://github.com/S4MUEL-404/ComfyUI-Prepack.git
pip install -r ComfyUI-Prepack/requirements.txt

Or search "Prepack" in ComfyUI Manager. Dependencies: PyTorch, NumPy, Pillow - already installed. Restart, look under đź’€Prepack. No models to download.

If a route never fires, check three things in order: is target_string non-empty, is string actually wired, and is the any override (which wins) populated? The console log the node prints will tell you which branch it took, which is faster than staring at wires.

Categoryđź’€Prepack

Inputs (7)

NameTypeDefaultDescription
target_stringSTRING—
trueopt*—
falseopt*—
anyopt*—
stringoptSTRING—
any_target_nameoptSTRING—
any_nameoptSTRING—

Outputs (1)

NameTypeDescription
output*—