Nodes/babydjac Nodes/Taglist Sanitizer
ComfyUI Node

Taglist Sanitizer

The Taglist Cleaner Every Prompt Workflow Needs

By babydjac·Created 7 months ago·Updated 5 months ago· 12
Taglist Sanitizer
    • sanitized
    taglist
    dedupetrue
    lowercasefalse
    strip_weightsfalse
    sort_alphafalse

    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:

    1. Split - on commas and newlines, dropping empties. So a multiline list and a comma list are treated the same.
    2. Strip weights (optional, off by default) - if a tag looks like (blonde_hair:1.3), it's reduced to blonde_hair. The regex only matches the exact (tag:number) shape, so it won't mangle plain parentheses.
    3. Lowercase (optional, off) - folds everything.
    4. Normalize whitespace - collapses runs of spaces inside a tag.
    5. Dedupe - removes exact duplicates (after the above, so Blonde Hair and blonde_hair - wait, no: it dedupes on exact string after transformation, meaning casing/whitespace differences are resolved if lowercase/normalize ran first).
    6. 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_weights is exact-shape only. It matches (tag:1.3) but not (tag:1.3):1.1 (nested weights) or tag:1.3 without parens. If your list has weird weight syntax, expect some to survive.
    • Dedupe happens after lowercase, only if you enabled it. Blonde hair and blonde hair are two different tags when lowercase is 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 1girl vs 1girl,) 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.

    CategorybabydjacNODES/Utils

    Inputs (5)

    NameTypeDefaultDescription
    taglistSTRING
    dedupeoptBOOLEANtrue
    lowercaseoptBOOLEANfalse
    strip_weightsoptBOOLEANfalse
    sort_alphaoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    sanitizedSTRING