Nodes/comfy_Pond_Nodes/🐳文本清理器
ComfyUI Node

🐳文本清理器

Strip the tags you're tired of from any prompt or caption

By Pondowner857·Created about a year ago·Updated 21 days ago· 45
🐳文本清理器
    • cleaned_text
    text
    tags
    mode删除包含标签/提示词的句子

    Text Cleaner (🐳文本清理器) is a dumb, useful little filter: give it a block of text and a list of words you're sick of, and it deletes them. Danbooru-style tag soup where "blurry" keeps sneaking in. A caption batch full of "watermark" and "text". A prompt that's accumulated every quality tag ever invented. This node is how you scrub that out before it ever reaches the text encoder - or before it pollutes a training caption.

    It's pure regex, no AI, no models. You feed it text and tags (both multiline), and the node parses the tag list by splitting on a broad set of separators - commas, semicolons, newlines, and Chinese/English punctuation (、。,;:?!etc.) - so you can paste tags in the way they arrive, not in a format you have to pre-clean. Then mode picks the flavor of deletion:

    • 删除包含标签/提示词的句子 (delete sentences containing the tags) - the default. Good for natural-language prompts or structured descriptions where the whole sentence is tainted, like "a photo taken at night, blurry" → drop the whole thing. It splits sentences on 。!?!? etc. (Chinese and English), keeps sentences that don't match, and reassembles.
    • 删除标签/提示词 (delete the tags themselves) - strips just the matching words and leaves the rest of the sentence standing. Better for tag lists, where you want to keep "masterpiece, best quality" and drop just "blurry" from the middle of a soup.

    Matching is case-insensitive, which saves you from the "Blurry" vs "blurry" dance. Output is a single cleaned_text STRING, so it slots in right before a CLIP Text Encode or a caption saver.

    What it's actually good for

    Two workflows. First, prompt hygiene: if you use a dynamic-prompt or tag-generation node upstream (this same pack ships several prompt nodes that throw around big tag lists), put a Text Cleaner between the generator and the encoder with your blacklist. Second, dataset scrubbing: before you train a LoRA or run a caption pass, strip watermark words and encoding artifacts out of captions in bulk - wire a Smart Batch Loader's text output through this and you've got an automated caption cleaner.

    Small print: the sentence mode's "contains" check is substring-based, so a tag like art will also kill a sentence containing "artist" - if your tags are short words, quote them with surrounding punctuation in mind, or use the delete-tags mode instead. Also, trailing whitespace and empty lines get cleaned up, so the output is usually tidier than the input, which is a bonus not a bug.

    Install

    Part of Pond Nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Pondowner857/comfy_Pond_Nodes
    cd comfy_Pond_Nodes
    pip install -r requirements.txt
    

    Restart after (or Manager → "comfy_Pond_Nodes"). No models, no optional deps - the whole node is the re module. The usual pack caveat: comfyui_HiDream-Sampler conflict causes console spam if both are installed.

    Category🐳Pond/text

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    tagsSTRING
    modeCOMBO删除包含标签/提示词的句子2 options: 删除包含标签/提示词的句子, 删除标签/提示词

    Outputs (1)

    NameTypeDescription
    cleaned_textSTRING