Nodes/DD-LogicNodes/DD Contains
ComfyUI Node

DD Contains

ComfyUI's missing `in` operator, plus the number trap you'll hit

By dumbdemon·Created 6 months ago·Updated a day ago· 0
DD Contains
  • to_check
  • check_what
  • if_contains
case_sensitivefalse

Core ComfyUI gives you comparisons - greater, equal, a boolean you can toggle - but never the question "does this text contain that word?" That's a one-line Python operation ("foo" in "foobar") and a ridiculous thing to want a custom node for, right up until you need it. You want to branch a workflow on whether a prompt string still carries a trigger word, or whether a filename contains upscale. DD Contains is exactly that, and nothing else.

It lives in DD-LogicNodes, a small pack by GitHub user DumbDemon, whose README line for it is "Returns true if any the source has any of the attached items (Strings, Ints, of Floats)" - typos and all. Honest framing for a plumbing node: no pixels, no models, no opinions about your sampler.

What it actually does

Read the source and the mechanism is almost disappointingly simple. The node stringifies both sides - f"{to_check}" and f"{this}" - and then does a plain Python substring test. case_sensitive is off by default, and the insensitive path runs .casefold() on each side first, so "Cat" and "cat" collide, but so do "Straße" and "strasse" (casefold is more aggressive than lowercase, so ß matches ss).

Two consequences fall out of that, and both are the reason this node is worth understanding before you wire it.

It's OR across slots, first match wins. The loop walks your check values and returns True the instant one matches; none matching means False. There's no "all of these must appear" mode here - that's a different node in the pack.

And it's substring, not equality. That's the whole point of a contains node, but it bites the moment you feed it numbers.

The inputs and the output

Three things, and only three:

  • to_check - the haystack. Accepts a String, Int, or Float, so it can be a prompt, a filename from a string node, a caption, or a bare number.
  • check_what - the needles, and this is the odd one. It's an autogrow input: you get check_value0, check_value1, and so on, with a + on the node to add more slots. Any one of them matching is enough.
  • case_sensitive - a boolean, default off (the author labels the two states "Sensitive" / "Insensitive"). Leave it off unless you genuinely care about casing.

One output: if_contains, a BOOLEAN. It goes into anything downstream that takes a boolean - this pack's own *Getter nodes and its DD Rerouter, a boolean widget you converted to an input on some other node, or a core Preview Any if you just want to watch it flip while you debug. The author's own playground workflow does exactly that last thing, wiring if_contains straight to a Preview Any with three string primitives feeding the check slots, which is a fine template to copy.

Installing it

Search DD-LogicNodes in ComfyUI Manager and install, or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/dumbdemon/DD-LogicNodes
# restart ComfyUI

There's nothing else to do. The pack's pyproject.toml declares dependencies = [], so no pip step, no model download, no checkpoint to place. You'll find the node under DD Logic Nodes → Logic Gates.

One real version caveat: this pack is written against ComfyUI's newer V3 backend API (from comfy_api.latest import io, io.ComfyNode, define_schema()), like core's own primitive nodes. Old installs won't be able to import it, and the autogrow + slots and the Sensitive/Insensitive labels are frontend features. If the node shows up greyed out, missing, or without its sockets, update ComfyUI before you file anything.

Where people get burned

Number mode is a digit match, not a numeric one. Type an Int into to_check and the check slots become Ints too - the slots share one type with the source, so the node is in string-mode or number-mode, never a mix. And in number-mode you're still doing a substring test on the stringified digits. So to_check = 100 "contains" 1, and to_check = 12.5 "contains" 2 and 5. If you wanted a numeric comparison, use DD Number Compare, not this.

A blank check value is not a skipped check. An empty string is contained in every string, so if one of your slots resolves to nothing, don't be shocked when the node answers True no matter what you feed it. Fill the slot or delete it from the node.

It's case-insensitive by default, deliberately. Most people want that. The one place it hurts is exact tag matching in a prompt rewriter, where "lora" matching inside "loras" or an unrelated word is not what you intended. Flip case_sensitive on for those.

Beyond that it's about as safe as plumbing gets: no state, no dependencies, same answer every run.

CategoryDD Logic Nodes/Logic Gates

Inputs (3)

NameTypeDefaultDescription
to_checkCOMFY_MATCHTYPE_V3
check_whatCOMFY_AUTOGROW_V3
case_sensitiveBOOLEANfalse

Outputs (1)

NameTypeDescription
if_containsBOOLEAN