ComfyUI Node

Process Tags

One node to clean, filter, and auto-BREAK your entire tag prompt

By alchemine·Created about a year ago·Updated 2 days ago· 2
Process Tags
  • clip
  • processed_text
  • filtered_tags_list
text
replace_underscorestrue
filter_tagstrue
filter_subtagstrue
auto_breakfalse
blacklist_tags
fixed_tags

ProcessTags is the pack's flagship prompt node: a single node that runs the whole tag-cleaning pipeline on your prompt - replace underscores, filter blacklisted tags, remove redundant subtags, and optionally auto-insert BREAK for the SDXL 75-token limit - in one pass. It's the "just make this prompt good" button for the Danbooru-tag workflow, and it's the node you reach for when your prompt has been assembled by an LLM or scraped off Danbooru and is full of the usual cruft.

If you've ever fed a raw tag dump into a sampler and watched it silently ignore half the tags or blow past the token window, this is the node that fixes both. It's really four of the pack's individual prompt nodes chained in order - ReplaceUnderscores → FilterTags → FilterSubtags → SDXLAutoBreak - but with one set of inputs and one output to wire.

How it works

The pipeline, in order:

  1. Replace underscores (replace_underscores, default on) - white_dress becomes white dress.
  2. Filter tags (filter_tags, default on) - removes anything matching your blacklist_tags, which supports the pack's wildcards (e.g. __color__ expands to every color in resources/wildcards.yaml).
  3. Filter subtags (filter_subtags, default on) - drops tags that are redundant subparts of a longer tag already present (dog and cat get removed from dog, cat, white dog, black cat).
  4. Auto BREAK (auto_break, default off) - needs a clip input; inserts BREAK tokens so each segment stays within the 75-token CLIP window, using the SDXL tokenizer.

fixed_tags lists tags that survive steps 2 and 3 no matter what - use it for the tags you absolutely want, like a character name or quality tags. The second output, filtered_tags_list, is a list of the tag groups that got removed at each filtering step, which is great for auditing why something disappeared from your prompt.

One thoughtful detail: the node preserves your original BREAK separators and whitespace when reassembling the text (auto_break off), so it doesn't mangle hand-placed BREAKs.

Inputs that matter

  • text - your prompt. The one required thing.
  • blacklist_tags - comma-separated tags to strip, wildcards allowed. This is the input you'll actually tune.
  • auto_break + clip - flip the toggle on and wire your CLIP in only if you're on SDXL and want token-safe BREAKs.

Outputs: processed_text (the cleaned prompt) and filtered_tags_list.

Install

Part of ComfyUI-Alchemine-Pack:

cd ComfyUI/custom_nodes
git clone https://github.com/alchemine/comfyui-alchemine-pack
pip install -r requirements.txt

Or via ComfyUI Manager (search "ComfyUI-Alchemine-Pack"). Only dependency is python-dotenv; no model downloads.

Common issues

The most common surprise is the subtag filter being too aggressive: dog, cat on their own are fine, but if your prompt mentions dog and separately white dog, the bare dog is dropped as redundant. That's by design (see the README example), and it's usually what you want - but if a "missing" tag bothers you, add it to fixed_tags. Auto-break silently does nothing unless clip is wired in; the toggle alone isn't enough. And remember the wildcards only expand what's defined in the pack's wildcards.yaml, so a __color__ you invent won't match anything.

CategoryAlcheminePack/Prompt

Inputs (8)

NameTypeDefaultDescription
textSTRING
replace_underscoresBOOLEANtrue
filter_tagsBOOLEANtrue
filter_subtagsBOOLEANtrue
auto_breakBOOLEANfalse
clipoptCLIP
blacklist_tagsoptSTRING
fixed_tagsoptSTRING

Outputs (2)

NameTypeDescription
processed_textSTRING
filtered_tags_listSTRING