ComfyUI Node

in (contains)

The simplest 'is it in there' test

By StableLlama·Created about a year ago·Updated about 17 hours ago· 48
in (contains)
    • BOOLEAN
    string
    substring

    This is the plainest membership test in the pack: does this string contain that substring? True or False. No index, no count, no fuss. And for a huge amount of workflow logic, that's exactly the answer you need.

    What it does

    in (contains) is Python's in operator for strings, wrapped as a node. It checks whether substring appears anywhere inside string and returns a BOOLEAN. The inputs:

    • string - the text being searched (required).
    • substring - what to look for (required).

    Output: one BOOLEAN.

    That's the whole node. Two inputs, one answer.

    Why you'd reach for it

    It's the trigger for conditional logic. "Does this prompt mention 'blurry'?" - if yes, route through a fixer. "Does this filename contain my project tag?" - gate the workflow branch. Wire the boolean into the pack's if/else or flow select nodes and you've got real decision-making without writing any code.

    This is exactly the pattern that gets this pack recommended in r/comfyui - people ask "how do I make my workflow decide things?" and the answer is a contains check feeding a control-flow node. It's the smallest piece of that whole mechanism, and the piece you'll use most.

    The easy miss

    It's a substring test, not a word test. "cat" matches "catalog" and "concatenate" too. If you need whole-word semantics - "cat" but not "catalog" - a substring check won't get you there; you'd split the string and compare pieces instead.

    It's also case-sensitive by default, which is worth remembering when your source strings are inconsistently capitalized. Run both sides through the pack's casefold node first if you want case-insensitive matching.

    Installing

    Part of Basic data handling by StableLlama. In ComfyUI Manager search "Basic data handling" → Install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart. Zero runtime dependencies - pure stdlib - so the install is instant and conflict-free.

    Where people get burned

    One Python quirk worth flagging: an empty substring is contained in every string, so contains with an empty substring always returns True. If your substring input can come up blank (say, from a node that produced an empty string), guard against it, or every check silently passes.

    CategoryBasic/STRING

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    substringSTRING

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN