ComfyUI Node

Text Compare

Branch your workflow on what the text says

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Text Compare
    • result
    • result_text
    text_a
    text_b
    modeequals
    case_sensitivetrue

    "Does this prompt contain 'watercolor'?" "Does this filename start with 'final'?" "Is this tag equal to that one?" Text Compare answers questions like that and hands you a boolean you can wire into a switch, gate, or conditional string node. It's the text-flavored sibling of the pack's Number Compare - the if-statement for strings.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. The comparisons are plain Python string operations; no models, no GPU, nothing to download beyond the repo.

    How it works

    Three required inputs:

    • text_a - the string being examined (multiline-friendly)
    • text_b - the string being tested against it
    • mode - the dropdown with five options: equals, not equals, contains, starts with, ends with

    One optional input:

    • case_sensitive - BOOLEAN, default True. Turn it off to compare case-insensitively (it lowercases both sides before comparing).

    Two outputs:

    • result - the BOOLEAN answer
    • result_text - the same answer as the string "True" / "False"

    The direction matters for contains, starts with, and ends with: they all test text_b against text_a. So for "does text_a contain text_b?", text_a is the haystack and text_b is the needle. Get them backwards and contains silently returns False.

    Where you'll use it

    • Conditional prompt handling. If a wildcard injected "cinematic", route the workflow down a different branch.
    • Filename/tag checks. Gate a save or a style pass on whether a string starts with or contains a marker.
    • Case-insensitive matching. Compare tags that might differ in case ("Flux" vs "flux") by flipping case_sensitive off.
    • Feeding Logic Gate. Combine several text checks with AND/OR/NOT for richer conditions.

    Installing it

    Whole pack, one install. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. Requirements (numpy, torch, opencv-python) are already satisfied by stock ComfyUI; no model downloads. When searching Manager, don't confuse it with cubiq's "ComfyUI Essentials" - a different, larger pack now in maintenance mode.

    Gotchas

    • Argument order. contains / starts with / ends with always test text_b in text_a. Wire them backwards and you'll chase a phantom bug.
    • case_sensitive affects every mode, including equals - with it off, "Hello" equals "hello".
    • Whitespace is not trimmed. "watercolor " with a trailing space does not equal "watercolor". If you're comparing raw user/wildcard text, trim or normalize first (the pack has a Text Trim node).
    • It returns a BOOLEAN; a result_text string is there for display/debug convenience.
    • Small, quiet pack - the source is the documentation.
    CategoryDebugPadawan/Text

    Inputs (4)

    NameTypeDefaultDescription
    text_aSTRING
    text_bSTRING
    modeCOMBOequals5 options: equals, not equals, contains, starts with, ends with
    case_sensitiveoptBOOLEANtrue

    Outputs (2)

    NameTypeDescription
    resultBOOLEAN
    result_textSTRING