Nodes/ComfyUI-PromptDrafter/Prompt De-Dupe - PromptDrafter
ComfyUI Node

Prompt De-Dupe - PromptDrafter

When your prompt says the same tag four times

By Carasibana·Created 8 months ago·Updated 6 months ago· 2
Prompt De-Dupe - PromptDrafter
    • cleaned_string
    • removed_items
    • duplicate_count
    input_string
    prose_threshold4
    force_underscoresfalse
    prefer_specified_weightstrue
    remove_spaces_around_commastrue

    If you build prompts by combining templates - a base, a style, a few LoRA trigger tags - you eventually produce something with blue eyes, blue_eyes, and (blue eyes:1.2) all in the same string. Prompt De-Dupe - PromptDrafter is the node that cleans that up before it hits the encoder. It's prompt hygiene, basically: feed it a messy combined prompt and it removes duplicate tags and phrases while resolving the conflicts between how the same concept is weighted and formatted.

    This is a surprisingly meaty little engine for what looks like a string cleaner. It parses your prompt into segments - booru tags, natural-language prose, weighted expressions, wildcards, LoRA references, nested brackets - and deduplicates across them with rules. blue eyes, blue_eyes, and (blue eyes:1.2) all collapse to one entry, and the version that survives is the one carrying the explicit weight, so (blue_eyes:1.2) wins. It processes BREAK and AND zones separately so one region's tags don't bleed into another's, and it deliberately protects special syntax: wildcards, <lora:...> references, prompt scheduling brackets, and nested grouping all survive untouched. That protection matters - a dedupe node that ate your LoRA tags would be worse than no dedupe node.

    The settings you'll actually touch

    • input_string - the prompt to clean. Feed it the output of a String Combiner or a PromptDrafter node.
    • prose_threshold - word count (1–20, default 4) above which text is treated as prose rather than tags. Booru tags are short; sentences aren't. Leave it at 4 until you have a reason not to.
    • force_underscores - replace spaces with underscores in tags only. Mostly for models whose vocabulary prefers blue_eyes over blue eyes.
    • prefer_specified_weights - when the same term appears once bare and once weighted, keep the explicit weight. Default on, and you'll usually want it on.
    • remove_spaces_around_commas - normalizes tag , tag and tag, tag into clean , spacing. Default on.

    Outputs are cleaned_string (use this), removed_items (a log of every merge it performed, useful for trusting or distrusting it), and duplicate_count (an integer you can wire somewhere or just read).

    Installing and what's bit people

    ComfyUI Manager (search "PromptDrafter"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Carasibana/ComfyUI-PromptDrafter
    

    Restart after. No extra dependencies, no model downloads - pure text processing. If you want to see the merges happening, the console logs everything.

    Troubleshooting, straight from the changelog: v1.3.4 fixed a startup crash (TypeError: can't access property "readOnly", inputEl is undefined) that a ComfyUI update introduced - if the pack won't even boot, update it. Earlier, v1.2.1 fixed prose_threshold losing its value on workflow reload by making it a required input, and v1.2.2 fixed LoRA dedupe failing when two <lora:...> tags sat adjacent with no comma between them. General advice: run it, check removed_items once, and if it mangled something, that's the evidence for which setting to flip.

    CategoryPromptDrafter

    Inputs (5)

    NameTypeDefaultDescription
    input_stringSTRING
    prose_thresholdINT41–20
    force_underscoresoptBOOLEANfalse
    prefer_specified_weightsoptBOOLEANtrue
    remove_spaces_around_commasoptBOOLEANtrue

    Outputs (3)

    NameTypeDescription
    cleaned_stringSTRING
    removed_itemsSTRING
    duplicate_countINT