Unique Tags
Dedupe your comma-separated prompt, then watch the order change
- string
The FairLab Unique Tags node removes duplicate entries from a comma-separated tag list. It's the cleanup step for prompts that got assembled from too many places: when you merge a base prompt, a style tag group, and a character set, the same tag shows up three times, and the result reads like a hoarder's closet. This node fixes that in one pass.
Tag hygiene is more than cosmetic. The KB's prompt-engineering doc covers how tag-heavy models weight each token - duplicates are wasted context, and a bloated prompt pushes other things out. There's also the practical argument: nobody wants to manually scan 60 tags for repeats.
How it works
The mechanism is short and worth understanding because it dictates the behavior. The node:
- Splits the input on commas and strips whitespace (
string_to_tags). - Throws the tags into a Python
set- dedup happens there. - Joins the survivors back with
", "(tags_to_string).
That's it. No model, no fuzzy matching, no case-folding.
The input and the catch
- string - a
STRINGsocket, markedforceInput, so it must be wired. Output is a singlestringsocket with the deduped list.
The catch is the set. Python sets are unordered, so the order of the output is arbitrary - it is not the order you typed. The README's description ("Deduplicate entries in a tag list") undersells this: it doesn't just dedupe, it reorders. If tag order matters to you - and for some CLIP encoders and heavily-tagged models it genuinely does - this node will scramble your sequence.
Also note what it doesn't do:
- Case-sensitive.
1girland1Girlare different tags to it. - Whitespace is handled, punctuation isn't.
"cat "and"cat"collapse (the strip catches it), but"cat,"and"cat"are different strings. - No dedup within a single token.
"blue blue sky"stays"blue blue sky".
So treat it as: exact duplicate comma-separated entries, collapse them, order unknown. For a final-prompt clean pass that's usually fine. For order-critical prompts, run it early in the assembly or don't run it at all.
When it's worth it
- After merging tag groups from multiple sources.
- Before a prompt goes into a CLIP encode, when you want a clean, compact list.
- As part of a tag-engineering chain with the pack's Prepend Tags, Append Tags, and Exclude Tags nodes - all of which share the same split/join convention, so they compose cleanly.
Installing it
One pack, all nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt
Restart ComfyUI, or install via Manager by searching "ComfyUI-FairLab". This node has no dependencies of its own, so if the pack imported, it's there.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |