Tag Duplicate Remover
Strip duplicate tags without wrecking their order
- STRING
Once you start chaining taggers, wildcard expansions and prompt builders together, your prompt text starts collecting junk. Two taggers both emit 1girl, your wildcard file expands masterpiece twice, and suddenly your positive prompt has the same tag stacked in three places. It's not just ugly - on CLIP-based models every repeated token gets counted again, so you're burning token budget and quietly over-weighting that tag. Tag Duplicate Remover is the 30-second fix: one input, one output, no settings to fight.
This is the node you drop in front of your CLIP Text Encode. Feed it the merged prompt string, and it returns the same list with only the first instance of each tag kept - order fully preserved, which matters more than people think. Danbooru-trained models read tags in order of importance, and most dedupe scripts you'll find shuffle or re-sort your tags as a side effect. This one doesn't touch the sequence at all.
How it works
The mechanism is embarrassingly simple, which is why it's reliable. It splits your string on the delimiter you give it, runs the list through dict.fromkeys() - which keeps the first occurrence of each entry and drops later ones - then rejoins with the same delimiter. No model, no API, no dependencies. It's pure string surgery that runs in microseconds.
Two inputs, both plain strings:
- tag_field - the text you want cleaned. Wire it in from another node (a tagger, a combiner, a wildcard processor).
- tag_delimiter - what separates your tags. Default is
,(comma-space), which is the convention for Danbooru-style tags. If your text uses a different separator, change it to match exactly.
The single output is a STRING you run straight into your positive prompt encode.
Install
This pack is "ComfyUI Nader Tagging" in ComfyUI Manager - search that and hit install, then restart. Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/NMWave/ComfyUI-Nader-Tagging
Then restart ComfyUI. There's no requirements.txt, no models to download, nothing to configure. The whole pack is a few hundred lines of plain Python.
Where people get burned
The dedupe is exact-match and case-sensitive. 1girl and 1Girl are different tags to this node, and so are 1girl and 1girl (note the trailing space). If your upstream nodes are inconsistent about whitespace, clean up the delimiter first or the duplicates survive.
The bigger trap is the delimiter itself. If you set tag_delimiter to , but your text actually uses , (comma-space), the split leaves spaces attached to the tags, and "1girl" vs " 1girl" won't match. When nothing gets removed, check the delimiter before you blame the node.
It's also worth saying what this doesn't do: it won't merge near-duplicates like cat and cats, and it only works within one run of the node. Put it upstream of any prompt assembly, not after, so every downstream consumer sees the cleaned string.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tag_field | STRING | — | |
| tag_delimiter | STRING | , | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |