Nodes/Basic data handling/convert to SET
ComfyUI Node

convert to SET

Deduplicate a list by turning it into a SET

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

One node, one guarantee: no duplicates

If you've ever had a list of prompts, tags, or filenames where the same value shows up three times and you just want each thing once - this is the node. It converts a LIST into a SET, and a set, by definition, can't contain duplicates. In one step you deduplicate your data and switch to the collection type that makes membership checks instant.

It's Python's set(list) wrapped for ComfyUI, and it's the simplest mental model of any node in the pack: in → unique values out.

How it works

Under the hood the node literally runs set(list). Two consequences are baked into that one line, and you should know both before you use it:

  • Order is not preserved. A set is an unordered collection. If you needed to keep the original order of your (now deduplicated) values, a set won't hold it - you'll get a unique order, just not necessarily yours.
  • Items must be hashable. Numbers, strings, tuples - fine. Lists, dicts, or other sets inside your list will throw a type error, because Python can't hash them. For text and number data (the common case) you'll never hit it; for nested data you will.

The output is a SET - the pack's own data type for a Python set passed as a single variable, same idea as the LIST type but unordered and unique. Feed it to the pack's SET operations (union, intersection, difference, contains) and those become the next step of your pipeline.

Inputs and outputs

  • list (LIST) - the list to deduplicate.

Output is a single SET containing every unique value from the input, order not guaranteed.

Installing it

Ships in Basic data handling by StableLlama, the r/StableDiffusion regular whose long model comparisons (Flux Klein 9B, RealVisXL) are more famous than his code. This pack is intentionally plain: zero runtime dependencies in its pyproject, no model downloads, no GPU usage - it's a clone-and-restart install.

Install via ComfyUI Manager (search "Basic data handling") or:

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

Restart ComfyUI; it's under Basic/LIST.

Troubleshooting

The two surprises are order loss and unhashable items. If your downstream logic depends on order, deduplicate a different way (or don't convert to a set at all - sort the LIST first so at least the loss is predictable). If you hit an "unhashable type" error, your list holds lists or dicts, and this node isn't the tool for that. And remember: the input is the pack's LIST type, not ComfyUI's native data list - those won't connect.

CategoryBasic/LIST

Inputs (1)

NameTypeDefaultDescription
listLIST

Outputs (1)

NameTypeDescription
SETSET