ComfyUI Node

prompt - dup

Dedupe a pasted tag list in one go

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
prompt - dup
    • STRING
    text

    Prompt lists from Civitai and prompt-sharing sites are filthy with duplicates. 1girl, masterpiece, best quality, 1girl, best quality - you've seen it a hundred times. On an SDXL-lineage anime model every tag is a word the model keys on, so duplicates aren't just ugly, they're wasted tokens and slightly distorted attention. prompt - dup from ymc-node-suite-comfyui collapses the list to unique tags, keeping the first occurrence of each and its position.

    It's the simplest node in the pack: one text input, one text output, nothing to configure. If you've ever wanted "dedupe this prompt" as a single box, this is it.

    How it works

    Under the hood it's a comma-split, then a dict.fromkeys() to drop repeats while preserving order, then a comma rejoin. First occurrence wins, so 1girl, ... 1girl becomes just the first 1girl - you don't lose the position where the tag first appeared, which matters because on SDXL-derived models earlier keywords get stronger attention.

    The one behavioral detail worth knowing: splitting is strictly on commas. a, b and a,b are different strings (the second has a space), so 1girl and 1girl look like distinct tags to this node. Feed it normalized text - run prompt - std first, or use the pack's prompt - input node - and dedupe gets much closer to a true no-op when it should be.

    Inputs and outputs

    • text - the prompt to dedupe (comma-separated tags)
    • STRING output - the deduped, comma-separated prompt

    That's the whole surface. Wire it between your prompt source and the CLIP Text Encode, or just use it as a preview/cleanup stage while you're iterating on a prompt.

    Installing it

    Same install as the whole pack - this node doesn't install alone:

    • ComfyUI Manager → search ymc-node-suite-comfyui → Install → restart, or
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    restart, and if you cloned manually also pip install -r requirements.txt (four small yors_* helper libs; the pack's auto-install is commented out in source, so a manual clone without them shows zero nodes). No model files, no GPU cost - this is pure Python.

    Find it by double-clicking the canvas and searching prompt / dup, or under the right-click ymc suite menu.

    Common issues

    • "It didn't remove my duplicate!" Almost always whitespace. 1girl , 1girl vs 1girl, 1girl - the space after the comma makes them different strings. Normalize first.
    • It doesn't merge near-duplicates like masterpiece vs masterpiece, best quality. It's exact-match dedupe, not a fuzzy cleanup. The pack's prompt - std handles the whitespace half; nothing here guesses about meaning.

    If you need dedupe per line while keeping multi-line structure - say each line is a prompt block you want left intact - the pack's prompt - dup (adv) variant does exactly that with two outputs.

    Categoryymc suite/text

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING