intersection
Keep only what's in every set — intersection, up to four sets at once
- set1
- set2
- set3
- set4
- SET
intersection returns a new SET containing only the elements that are present in all of the input sets. If union is "gather everything" and difference is "what's only in the first one," this is "what do they agree on."
That "agree on" framing is where it earns its place. Imagine you have two tag sources - a prompt-tag set and a style-keyword set - and you want the keywords that appear in both. Or you've split a big pool into several sets and need the values common to every partition. Intersection is the one-wire way to find them. Because the output is a SET, it composes with the rest of the category: feed the result into contains to test membership, length to count the overlap, or convert to LIST to iterate it.
How it works
Under the hood it's Python's intersection_update applied in sequence. The node copies set1, keeps only what's in set2, then keeps only what's in set3 if you provided one, then set4. The result is the common core across everything you wired in.
The mechanism has two practical consequences:
- Non-destructive.
set1is copied, so your input sets survive for use elsewhere. - The empty set is a valid answer. If the sets share nothing, you get an empty set back - not an error. Feed that into length if you want to branch on "no overlap."
Inputs and output
set1,set2(SET) - the two required sets.set3,set4(SET) - optional. Add them when you need agreement across more than two pools.- SET (output) - elements present in every input set.
That's the whole schema. Notably, unlike the single-pair nodes, intersection handles up to four sets in one shot - handy when comparing several tag pools without a chain of nodes.
Installing
It's part of Basic data handling by StableLlama. Use ComfyUI Manager - search "Basic data handling" - or clone manually:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI after installing. Zero dependencies, no model downloads - this whole pack is pure Python, so installation is instant and can't clash with your other custom nodes.
Common issues
The predictable gotcha: elements have to match exactly to survive an intersection. "cinematic" and "Cinematic" are different values, and 1 vs 1.0 are the same one - so case and type mismatches silently shrink your result. Normalize inputs before intersecting if your sources are sloppy. And when the result surprises you by being empty, check the inputs with length before assuming the node is broken - empty-in, empty-out is correct behavior.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| set1 | SET | — | |
| set2 | SET | — | |
| set3opt | SET | — | |
| set4opt | SET | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SET | SET | — |