Remove Caption Tokens
Strip Exact Tags Out of a Caption Without Losing the Rest
- string
Tagger output is great until it isn't. A WD14-style tagger will happily hand you masterpiece, best quality, 1girl, ... - and half the time you don't want those boilerplate quality tags in your training captions, or you want to drop a character tag that the model already knows. IPT-RemoveCaptionTokens is the surgical version: give it a caption and a comma-separated list of tags to remove, and it removes only the exact matches, preserving the order and content of everything else.
Paired with Merge Caption Tokens and Normalize Prompt Tokens, it completes the pack's caption-cleaning trio - merge what you want, normalize the format, remove what you don't. All three feed the same downstream: caption files, training datasets, and clean prompts.
How it works
The string input is split into tokens on , and . . The remove input is split on commas (with each item trimmed) and treated as a set of exact tokens to delete. Then it's a simple filter: every token not in the remove set survives, in original order. Exactness is the contract - long hair removes long hair but not longhair or long hair,. If remove is empty or unconnected, the source passes through unchanged.
Inputs and outputs
string(optional, STRING) - the caption text to filter.remove(optional, STRING) - comma-separated tokens to remove. Type them directly or wire them in from another node.string(output, STRING) - the filtered caption.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
cd comfyui-info-prompt-toolkit
pip install -r requirements.txt
Restart, or ComfyUI Manager → "ComfyUI-Info-Prompt-Toolkit". ComfyUI 0.17.0+. No models.
Common issues
Exact-match is both the feature and the trap. Tagger output can use slightly different spellings (1girl vs 1 girl) or add qualifiers, and none of those count as the same token - if a tag isn't disappearing, check the whitespace and spelling byte-for-byte, or normalize the string first. Also remember the split is on , (comma-space): if your source text uses , without a trailing space, tokens won't split where you expect and the removal will miss. Run Normalize Prompt Tokens first and this node behaves exactly as documented. It's a dumb, dependable filter, and that's precisely what you want when cleaning 10,000 captions in a batch.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| stringopt | STRING | Caption token text to filter. Tokens are split on ', ' and '. '. | |
| removeopt | STRING | Caption tokens to remove from string. Can be typed directly or provided from another node. Split on ',' with trimming for each item and matches exact tokens only. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |