Nodes/Basic data handling/convert to SET
ComfyUI Node

convert to SET

Convert a list into a SET — say goodbye to duplicates

By StableLlama·Created about a year ago·Updated 4 days ago· 48
convert to SET
  • list
  • SET

A set is the mathematical cousin of a list with two iron rules: every value appears exactly once, and order doesn't matter. DataListToSet takes a data list and converts it into a SET - which is the easiest way in ComfyUI to strip duplicates out of a collection.

One input, list, one output, SET. The conversion does two things you need to know about before you use it, because both are usually features but can surprise you.

What actually happens

Under the hood it's Python's set(), and that's exactly as simple - and as consequential - as it sounds:

  1. Duplicates vanish. ["a", "b", "a", "c"] becomes {"a", "b", "c"}. If you had a batch of 100 prompts with repeats and only want the unique ones, this is the one-step dedupe.
  2. Order is not preserved. A set is unordered by design. If the order of your items mattered, a set is the wrong destination - and converting back to a list later will not restore the original order, only some order.

That second rule is where people get burned. Deduplicating a list of tags or styles? Perfect. Deduplicating an ordered batch of frames and expecting the sequence back? You'll get the right items in a scrambled order. Plan accordingly.

Why you'd use it

The headline use is deduplication - clean up a tag list, a candidate set, a list of model names gathered from multiple sources. Sets also make membership tests fast, and the pack's set-family nodes (union, intersection, difference, subset checks) are the reason to convert in the first place: those operations only exist on SET types. If you want the set back as a normal collection for processing, the pack's SetToDataList or SetToList nodes do the reverse trip.

How the types differ

This is the middle of the pack's three-way type story: data list (items processed individually), LIST (ordered, duplicates preserved, passed as one variable), SET (unique values only, order irrelevant, fast membership). Convert between them freely - but choose the destination based on which property you actually need. The README's rule of thumb: need order or duplicates? LIST. Need uniqueness or set math? SET.

Installing it

Part of StableLlama's Basic data handling pack - pure Python, zero dependencies, no model files:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI, or search "Basic data handling" in ComfyUI Manager. No pip dependencies to install, so setup is friction-free.

Common issues

The order-loss is the big one - if a downstream node assumes sequence, you'll get confusing output that's technically correct. And remember the dedupe is aggressive: any two items that compare equal collapse into one, so if "2" (string) and 2 (int) both appear, they stay separate (different types), but 2 and 2.0 will not. Keep your inputs type-consistent and the conversion behaves exactly like you'd expect.

CategoryBasic/Data List

Inputs (1)

NameTypeDefaultDescription
list*

Outputs (1)

NameTypeDescription
SETSET