Taglist Sanitizer
The Taglist Cleaner Every Prompt Workflow Needs
- sanitized
Tag lists rot. You paste one in from a picker, it has duplicates, mixed casing, a stray (tag:1.4) weight from a previous experiment, and a couple of blank lines. Feed that mess straight into a text encoder and you get a prompt that's fine but messy - and messy prompts are harder to debug, harder to compare, and occasionally break the weight syntax of tags you actually care about. The Taglist Sanitizer from the babydjacNODES pack is the clean-up step: tag list in, tidy comma-separated list out.
It's local, free, instant, and deterministic - the kind of node you drop between a tag source and a merge/encoder and never think about again.
How it works
Pure string processing in Python, in this order:
- Split - on commas and newlines, dropping empties. So a multiline list and a comma list are treated the same.
- Strip weights (optional, off by default) - if a tag looks like
(blonde_hair:1.3), it's reduced toblonde_hair. The regex only matches the exact(tag:number)shape, so it won't mangle plain parentheses. - Lowercase (optional, off) - folds everything.
- Normalize whitespace - collapses runs of spaces inside a tag.
- Dedupe - removes exact duplicates (after the above, so
Blonde Hairandblonde_hair- wait, no: it dedupes on exact string after transformation, meaning casing/whitespace differences are resolved if lowercase/normalize ran first). - Sort (optional, off) - alphabetical.
The output is the surviving tags joined with ", ".
The inputs that matter
- taglist - required, the raw list to clean.
- strip_weights - turn this on when your list is full of
(tag:1.2)leftovers from a previous weighting experiment. Leave it off if the weights are intentional - this is a cleaning node, not a reweighting one (that's the pack's separate Weight Adjust). - dedupe - on by default; keep it.
- lowercase / sort_alpha - flip on when you want canonical, stable output for seed comparisons.
Output: a single STRING, sanitized.
Install
ComfyUI Manager → babydjacNODES, or git clone https://github.com/babydjac/babydjacNODES into ComfyUI/custom_nodes, restart, hard-refresh. No extra pip deps.
Gotchas
strip_weightsis exact-shape only. It matches(tag:1.3)but not(tag:1.3):1.1(nested weights) ortag:1.3without parens. If your list has weird weight syntax, expect some to survive.- Dedupe happens after lowercase, only if you enabled it.
Blonde hairandblonde hairare two different tags whenlowercaseis off - which is usually what you want, but can surprise you. - It won't fix the list, just clean it. Bad tags, hallucinated tags, and duplicates-that-aren't-exact (like
1girlvs1girl,) need different tools.
Every serious prompt workflow has a dirty-middle problem. This is the two-minute fix for it, and it chains perfectly with the pack's Prompt Merge - sanitize each source, then merge them.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| taglist | STRING | — | |
| dedupeopt | BOOLEAN | true | — |
| lowercaseopt | BOOLEAN | false | — |
| strip_weightsopt | BOOLEAN | false | — |
| sort_alphaopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| sanitized | STRING | — |