ComfyUI Node

Text Compare

A boolean for 'is this prompt about X?' — without writing a regex

By 1hew·Created about a year ago·Updated 7 days ago· 33
Text Compare
    • bool
    a
    operator==
    b

    Half of "smart" workflow automation is just asking a question about text and getting a yes/no out of it. Does this prompt mention the character? Is this tag already in my string? Does this filename end the way I expect? Text Compare is the yes/no machine: two strings in, one boolean out, with a menu of comparison operators so you rarely need to hand-write a regex.

    What it's for

    It's the routing node. Boolean output feeds switches, conditionals, and logic branches - "if the prompt contains 'portrait', use the portrait settings; otherwise default." This is how you make a workflow adapt to its input instead of hard-coding one path. In a pack full of text and mask utilities, this is the decision-maker that ties the branches together.

    How it works

    Straightforward comparison with a friendly operator list. The default == / != are plain string equality. The subset symbols are the ones that take a second to learn but are where the power is:

    • means "a is inside b" (substring) - the one you'll use most.
    • means "b is inside a".
    • / are the negations.

    Plus startswith, endswith, and regex - the escape hatch when you need real pattern matching (implemented via re.search, so the pattern is matched anywhere in a, not anchored). The operator set mirrors the symbols used elsewhere in the pack's logic nodes, so once you know one you know them all.

    The inputs that matter

    • a (STRING) - the value you're testing.
    • operator (COMBO) - ==, !=, , , , , startswith, endswith, regex.
    • b (STRING) - the value you're comparing against.

    One output: bool (BOOLEAN).

    Installing it

    ComfyUI Manager → search ComfyUI-1hewNodes → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/1hew/ComfyUI-1hewNodes
    

    Restart ComfyUI. Pure string logic - no models, no downloads. The pack's requirements are heavy anyway, and it needs a current ComfyUI (comfy_api.latest API).

    Common issues

    Operator direction is the classic trap: is "a in b," so to ask "does my prompt contain the word cat" you put the prompt in a and cat in b with - get it backwards and you're asking whether the word cat contains the whole prompt. The subset operators are case-sensitive too; use regex with a case-insensitive flag if you need to ignore case. And regex failures return False silently rather than erroring, which is convenient until a mistyped pattern makes every comparison quietly false - test your pattern in isolation first.

    Category1hewNodes/logic

    Inputs (3)

    NameTypeDefaultDescription
    aSTRING
    operatorCOMBO==9 options: ==, !=, ⊂, ⊃, ⊄, ⊅, +3
    bSTRING

    Outputs (1)

    NameTypeDescription
    boolBOOLEAN