ComfyUI Node

Tidy Tags

One node to dedupe and clean your comma-tag prompt mess

By akierson·Created 2 years ago·Updated 2 years ago· 0
Tidy Tags
    • string
    string

    If you prompt anime and SDXL-lineage models, your prompt is a comma-separated tag list - 1girl, long hair, red dress, park, sunlight. That's not a stylistic choice, it's the interface: Danbooru-trained checkpoints like Illustrious, NoobAI and Pony V6 understand that vocabulary better than prose. The moment you start building those lists mechanically - merging tags from a few sources, pasting a tag dump from a booru or an autotagger, unioning the outputs of two text nodes - you inherit the mess: double commas, stray spaces, and the same tag three times. Tidy Tags is the first node in the tiny akierson/ComfyUI-textnodes pack, and it does exactly one boring job: take a messy comma string, normalize it, and hand back a clean, deduped tag list.

    What it actually does

    Under the hood it's pure Python stdlib - no dependencies, no model, no network call. Feed it a string and it:

    • collapses runs of commas and the whitespace around them down to a single comma;
    • collapses double spaces;
    • strips leading and trailing junk;
    • splits on commas and removes duplicates, keeping the first occurrence of each;
    • rejoins as tag1, tag2, tag3 and rewraps any BREAK tokens as BREAK.

    Two details are worth caring about. First, dedup keeps first occurrence and order - and order isn't cosmetic. On everything SDXL-derived, earlier tags get stronger attention, so "important concept first" is a real rule; Tidy Tags won't reshuffle, which is exactly what you want from a cleaner. Second, BREAK is preserved as a single token. That matters on SD 1.5 or other 77-token-chunk CLIP models where BREAK starts a new chunk, and it's harmless on newer LLM-encoded models that ignore it.

    The input that matters

    There's one input, string, and one output, string - that's the whole node. The field is multiline and marked forceInput, which is ComfyUI's way of saying it's built to be wired rather than typed. Connect a text node's string output into it, or chain it right before a CLIP Text Encode. It even defensively accepts a list and joins it with commas, though you'll normally hand it a STRING. The output feeds a CLIP Text Encode prompt input (or another text node) with zero surprises.

    Installing it

    Both nodes in this pack ship together, and install is the easiest it gets. ComfyUI Manager → Install Custom Nodes → search "ComfyUI-textnodes" (it's registered in the Comfy registry), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/akierson/ComfyUI-textnodes
    

    then restart ComfyUI. There's no requirements.txt, no model download, nothing to collide with your other custom nodes. Given this ecosystem's reputation for dependency hell and the occasional malicious package, a zero-dependency stdlib node is about as safe as they come - though, as ever, you read the source before you trust it.

    Gotchas

    Dedup is exact-match and case-sensitive. The spacing cleanup catches 1girl vs 1girl , but longhair and long hair are different tags to it, and it won't convert underscores, sort, or know your model's vocabulary. It's a string cleaner, not a prompt doctor - give it good tags and it'll keep them good.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    stringSTRING