contains
Contains — the membership test that ends 'is it in the list?' guesswork
- list
- value
- contains
The contains node answers the simplest question in programming: is this value in this list? It takes a LIST and a value, and returns a single True or False. It's the kind of node that looks too trivial to be useful right up until you need it - then it's the thing that lets a workflow check "is this filename already processed?" or "is this checkpoint one I'm allowed to use?" before it does anything else.
How it works
It's a one-line wrapper around Python's in operator:
return (value in list,)
The value input accepts any type (*), and matching is exact equality - 42 does not match "42", and 1 does not match 1.0 if the list literally stores the int while you test with a float. Well, careful: in Python 1 == 1.0 is True, so the int and float will actually match. The thing that won't match is a string versus a number. If you're testing values that went through casting, match the types.
The output is a BOOLEAN named contains, ready to feed straight into the pack's if/else, switch/case, or disable flow nodes for actual routing.
Where you'd use it
- Deduplication guards. Check "is this seed already in my LIST of used seeds?" before adding it, so you don't rerun a generation.
- Allow/deny lists. Keep a LIST of allowed checkpoints or filenames;
containsbecomes the gate. - State checks. If you've been collecting step results with
append, a quickcontainstells you whether a particular result ever happened. - Batch validation - combine with
allto say "every required value is present."
It's also genuinely handy for debugging: wire a hardcoded value into value and a create LIST into list, and you can confirm your list-building logic actually assembled what you think it did.
Installing
Part of the "Basic data handling" pack by StableLlama. ComfyUI Manager: search "Basic data handling", install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI. Zero dependencies, no models to fetch - the pack is pure Python wrappers around built-ins, so the whole install is a clone and a restart.
Gotchas worth knowing
- If you only need to know how many times a value appears, the sibling
countnode gives you the number;containsjust says yes/no. Pick per job. - It's an exact-equality test. Whitespace, casing, and type all matter -
"HighRes"and"highres"are different values. - Works on the pack's LIST type (a single Python list variable), not a native ComfyUI data list. Different collection types, different nodes.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list | LIST | — | |
| value | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| contains | BOOLEAN | — |