Nodes/ComfyUI-ZML-Image/ZML_文本条件
ComfyUI Node

ZML_文本条件

Route execution based on text

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_文本条件
  • 输入文本
  • 布尔结果
判断方式存在
检测文本

ComfyUI is a graph, but every so often you need it to make a decision: if this prompt contains "nude", route it one way; if it's empty, another. ZML_TextCondition is that decision node. It takes any value (the input socket is wildcard-typed, so it accepts text, an image, a number - anything), runs one of eight predicates against a detection string, and sends the input down the matching branch. It also hands you the raw boolean, so you can wire logic without forking your data at all.

The eight judgment modes

The 判断方式 dropdown is the whole node. The modes:

  • 存在 / 不存在 - does the detection text appear in the input (or not).
  • 开头有 / 开头无 - starts with the detection text, or doesn't.
  • 结尾有 / 结尾无 - ends with it, or doesn't.
  • 为空 / 不为空 - is the input empty or not.

It's a string predicate under the hood - anything non-string gets stringified first, so an integer 42 and the text "42" behave the same. The 检测文本 box is what you're testing for; leave it empty and the "exists" modes degenerate into "is the input non-empty," which is still useful.

Outputs and the execution trick

Three outputs: , , and 布尔结果.

  • 布尔结果 - the raw True/False, for wiring into a boolean switch or another logic node.
  • 真 / 假 - the same input value routed down whichever branch matched.

The clever part is what happens on the branch you didn't take: for non-primitive types the node returns an ExecutionBlocker, which tells ComfyUI to skip the entire downstream subgraph of that branch. So a model, latent, or image connected to the unselected output never executes - this isn't just routing a value, it's pruning the graph. One caveat the author built in: for plain integers and strings, the unselected branch gets an empty value (0 or "") instead of an ExecutionBlocker, because downstream text/int nodes handle empty values more gracefully than they handle blocked execution.

Where it fits

This is the "gate" for conditional workflows: inspect the prompt and only run the img2img branch if it mentions a character, only append an upscale pass if the text block says "4k", only run the NSFW-filter branch if a tag list contains a banned tag. It's the same if-statement pattern the KB's node-plumbing notes describe for switches, applied to text. It's marked as an output node, so it always runs and always makes the decision - good, because the whole point is that it fires every time.

Install

ComfyUI Manager → search "ComfyUI-ZML-Image", or cd ComfyUI/custom_nodes && git clone https://github.com/zml-w/ComfyUI-ZML-Image, restart. Displayed as ZML_文本条件 in the Chinese-default UI; the English patch translates it. No models or extra deps.

Categoryimage/ZML_图像/逻辑

Inputs (3)

NameTypeDefaultDescription
输入文本*
判断方式COMBO存在8 options: 存在, 不存在, 开头有, 开头无, 结尾有, 结尾无, +2
检测文本STRING

Outputs (3)

NameTypeDescription
*
*
布尔结果BOOLEAN