Nodes/ComfyUI-PainterNodes/Painter String Cleaner
ComfyUI Node

Painter String Cleaner

Your prompts are full of bracket junk — Painter String Cleaner strips it

By princepainter·Created 7 months ago·Updated 5 days ago· 194
Painter String Cleaner
    • original_text
    • cleaned_text
    text
    eliminate_pattern[]
    replace_with

    PainterStringCleaner is a one-trick text utility: give it a string, tell it what brackets to hunt for, and it deletes everything sitting between them - or swaps it for whatever you like. It exists because prompts accumulate cruft. Per-segment video prompts come out of prompt builders full of [weight tags], [lora:...], or quality-bracket annotations you don't want fed into the CLIP encoder, and stripping those by hand across a list of segments is exactly the kind of busywork a node should do instead.

    How it works

    It's deliberately simple regex. The first character of eliminate_pattern is treated as the left delimiter, the last character as the right delimiter, and the node removes everything between them. So the default [] strips square-bracket contents, () strips parentheses, 「」 strips whatever's in Japanese quotes. Don't reach for it expecting general regex power - it's bracket-pair stripping, full stop. For real pattern matching you want a dedicated regex node; for "get the square tags out of my prompt list," this is the whole job.

    The other quirk worth knowing: if eliminate_pattern is empty or shorter than two characters, the text passes through untouched. That's not a bug, it's a safe default - you never lose data by wiring this in wrong, you just don't get cleaning.

    The fields

    • text - multiline string input. The thing you're cleaning.
    • eliminate_pattern - default []. The two delimiter characters.
    • replace_with - default empty. What the removed chunk becomes; set it to , if you want to collapse the gap instead of leaving a hole.

    Outputs are original_text and cleaned_text - both strings, both always produced, so you can keep the source around for comparison or wire the original into one branch and the cleaned version into another.

    Install

    Same pack as the rest: search "PainterNodes" in ComfyUI Manager, or

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

    Restart and it's under the PainterNodes category. No models, no heavy deps - it's pure re against a string. This is the node you string together (pun intended) in front of a CLIPTextEncode when your video prompt list has annotations that only existed to help you, not the model.

    CategoryPainterNodes

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    eliminate_patternSTRING[]
    replace_withSTRING

    Outputs (2)

    NameTypeDescription
    original_textSTRING
    cleaned_textSTRING