Nodes/OmniNodes/Prompt Cleaner 🧹
ComfyUI Node

Prompt Cleaner 🧹

De-mess a prompt after wildcards and concatenation did their worst

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Prompt Cleaner 🧹
    • cleaned_text
    • removed_count
    β—„textβ–Ί
    β—„case_insensitive_deduptrueβ–Ί
    β—„lowercasefalseβ–Ί
    β—„max_tags0β–Ί

    The moment your prompt stops being a hand-typed sentence and becomes something assembled from wildcards, combiners, and random pickers, it turns into a mess: duplicate tags, double commas, stray whitespace, "blue hair, blue hair, blue hair" because two wildcard files both drew the same card. Prompt Cleaner 🧹 is the node you drop between your prompt assembly and your CLIP encoder. It normalizes the string - strips duplicate tags, collapses whitespace, drops empty leftovers, and optionally lowercases or truncates - and hands back a clean prompt plus a count of what it removed.

    It's the kind of node that looks pointless until you run a batch of wildcard-composed prompts and see the trash that was silently riding into the encoder. Then it's indispensable.

    How it works

    It splits the text on commas, strips whitespace around each tag, removes exact duplicates (case-insensitive when case_insensitive_dedup is on, which it is by default - so "Blonde Hair" and "blonde hair" collapse to one), collapses internal whitespace runs to a single space, and drops the empty tags left behind by trailing or doubled commas. Two optional switches: lowercase normalizes case entirely, and max_tags (0 = off, up to 500) truncates to the first N tags - useful when your assembled prompt is running long.

    Outputs are cleaned_text and removed_count, the latter being genuinely useful: a removed_count of 0 tells you the cleaning pass did nothing, which is exactly the signal you want when debugging why a batch came out unexpectedly uniform.

    The inputs that matter

    text is the only wire. The three widgets you'll actually touch are case_insensitive_dedup (leave it on), max_tags (set it when token budgets are tight), and lowercase (only if your workflow needs it - lowercase prompt strings are a real look, but not for everything).

    It slots naturally after Prompt Combiner or a wildcard builder, and before the CLIP encoder. In fact, pairing it with the pack's Prompt Combiner is the canonical chain: combine fragments, clean the result, encode.

    Installing it

    Part of OmniNodes:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/TensorVizion/OmniNodes
    

    Restart ComfyUI (or search "OmniNodes" in ComfyUI Manager). No extra dependencies - pure Python, uses re. Registers under TensorVizion/Prompt. If it doesn't appear, restart completely and check the terminal for [OmniNodes] βœ… Loaded lines.

    One honest note: dedup is exact-match (case-insensitively), not semantic. It won't merge "cat" and "kitty", and it shouldn't - you don't want a cleaner guessing at meaning. For mechanical mess, it's exactly right.

    CategoryTensorVizion/Prompt

    Inputs (4)

    NameTypeDefaultDescription
    textSTRINGβ€”
    case_insensitive_dedupBOOLEANtrueβ€”
    lowercaseBOOLEANfalseβ€”
    max_tagsINT00–500β€”

    Outputs (2)

    NameTypeDescription
    cleaned_textSTRINGβ€”
    removed_countINTβ€”