ComfyUI Node

Text Condition

A ComfyUI node in Zuellni/Text with 7 inputs and 4 outputs.

By Zuellni·Created 3 years ago·Updated 3 years ago· 43
Text Condition
  • images
  • latents
  • masks
  • IMAGES
  • LATENTS
  • MASKS
  • RESULT
var_1
condition==
var_2
interruptfalse

The pack's text nodes exist for one job: letting an LLM (running in text-generation-webui) generate and manipulate prompts mid-workflow. That works great right up until the LLM hands back garbage - an empty string, a prompt that's 3 words, a number way out of range. Text Condition is the gate that catches it. It compares two values with a range of operators, passes your tensors through if the check succeeds, and can kill the whole run if it fails.

What it is

Text Condition takes var_1 and var_2 (strings), a condition operator, and an interrupt toggle. It evaluates the comparison and returns RESULT as the string "true" or "false", plus passthrough copies of any images/latents/masks you connected. If the result is false and interrupt is on, it raises an interrupt and stops generation - everything downstream halts.

The operators

Nine of them, and here's the part people miss: if both values parse as floats, it compares them numerically. The node tries float(var_1) / float(var_2) first and falls back to strings. So var_1 = "64", var_2 = "128", condition < correctly evaluates true, even though they arrived as strings. That makes it genuinely useful for checking outputs of numeric computations (e.g. an upscale factor, a token count, a generated number).

  • Equality and inequality: ==, !=
  • Numeric/string ordering: <, <=, >, >=
  • Substring/text checks: contains, starts with, ends with

How you'd use it

The canonical workflow: LLM generates a prompt → something like Text Format assembles it → you want to guard before the prompt reaches a CLIP encoder. Wire the LLM's output into var_1, set condition to starts with / a length check, or route a numeric value in and set < / >. If the check fails and interrupt is on, the run stops instead of spending minutes generating from a garbage prompt. That's the whole value: fail fast instead of wasting a generation.

The tensors passthrough is the quieter feature - you can place the gate in the middle of a pipeline without rerouting your images: they come out the other side unchanged when the check passes.

The gotchas

  • false without interrupt doesn't stop anything. It just returns (None, None, None, "false") - the tensor outputs go null (which may break downstream nodes) but the run continues. If you want a hard stop, interrupt must be on.
  • contains and the ordering operators are case-sensitive. "Cat" doesn't contain "cat". Normalize your strings upstream if that matters.
  • A false result nulls your tensors, so wire the passthrough into anything that must keep running only when the check passes - otherwise you'll feed None into a sampler.

Install

Part of Zuellni/ComfyUI-Custom-Nodes, via ComfyUI Manager (search "Zuellni") or:

cd ComfyUI/custom_nodes
git clone https://github.com/Zuellni/ComfyUI-Custom-Nodes

No extra dependencies beyond what ComfyUI ships. Note the pack's text nodes are built for text-generation-webui running with --api - Text Condition itself is just a comparator, so it works standalone, but if you got here expecting the full LLM loop, that's the other half. And the pack is archived - fine for a comparator, but don't expect fixes.

CategoryZuellni/Text

Inputs (7)

NameTypeDefaultDescription
var_1STRING
conditionCOMBO==9 options: ==, !=, <, <=, >, >=, +3
var_2STRING
interruptCOMBOfalse2 options: false, true
imagesoptIMAGE
latentsoptLATENT
masksoptMASK

Outputs (4)

NameTypeDescription
IMAGESIMAGE
LATENTSLATENT
MASKSMASK
RESULTSTRING