ComfyUI Node

Text Judge

The closest thing ComfyUI has to an if-statement for text

By wwsmiao·Created 4 months ago·Updated 4 months ago· 0
Text Judge
    • result
    • boolean
    input_a
    operatorequals
    input_b
    invertfalse

    ComfyUI has no if statement. What it has is nodes that hand you a boolean socket, and then whatever switch or gate node you've installed decides what to do with it. TextJudge is how you get that boolean out of text: it tests input_a against a condition and returns "true"/"false" as a STRING plus the real thing as a BOOLEAN output. That second socket is the one you wire into a switch to make a branch in the graph.

    The operator dropdown has fourteen conditions, and they cover the cases you'd actually want. Equals and not_equals for exact matches. contains / not_contains, starts_with, ends_with for substring checks. is_empty / not_empty for "did this node produce anything" - the single most useful gate in a workflow that runs an LLM, because LLMs love to return nothing. is_digit, is_alpha, is_alnum for character-type checks. And three length comparisons - length_gt, length_lt, length_eq - where input_b is the number you compare against (as a string, which the node parses with int()).

    The inputs that matter: input_a (the text being tested), operator (the test), and input_b (the compare-to value, needed for equals/contains/length ops). There's also an invert toggle that flips the result - a small thing, but it saves you from hunting for a "not" operator when the condition you want is the negation. Mechanism-wise it's dead simple: Python string methods and comparisons under the hood, with one soft-failure detail worth knowing - if you feed a non-numeric input_b to a length_* op, the node returns false rather than erroring.

    The genuinely useful pattern is the README's framing plus one obvious step: run AIChatAPI or an OCR/LLM output, feed the result into TextJudge with not_empty or contains, and branch the workflow on the BOOLEAN - retry the generation, fall back to a default prompt, or skip a save. TextLength's INT output also pairs well: check a generated prompt's length before it goes to an encoder. This is plumbing in the best sense - it makes your graph behave like a program instead of a one-way pipeline.

    Install is the whole pack in one command:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
    

    Restart ComfyUI, look under wwdm-aicd. No dependencies beyond stdlib and what ComfyUI bundles; the README's pip install -r requirements.txt is vestigial because the repo has no requirements.txt. The README and source comments are in Chinese - the pack author is Chinese-speaking, and it shows in the docs, though every widget label is English.

    The catch is that a BOOLEAN output is only useful if you have a node downstream that consumes booleans - a switch, an Anything Anywhere style router, or a conditional save. If you don't have one yet, TextJudge gives you a pretty red/green socket and nowhere to plug it. That's not a flaw in the node; it's a reminder that the plumbing layer needs its full set of parts. Judge is the sensor; the switch is the actuator. Get both.

    Categorywwdm-aicd

    Inputs (4)

    NameTypeDefaultDescription
    input_aSTRING
    operatorCOMBOequals14 options: equals, not_equals, contains, not_contains, starts_with, ends_with, +8
    input_boptSTRING
    invertoptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    resultSTRING
    booleanBOOLEAN