Nodes/ComfyCollectorNodes/String Merge Unique (CCN)
ComfyUI Node

String Merge Unique (CCN)

Merge tag lists without the duplicates

By valkymaera·Created 4 months ago·Updated 10 days ago· 1
String Merge Unique (CCN)
    • text
    string_1
    string_2
    string_3

    Danbooru-style tag blocks are the classic case: you have a character tag list and a style tag list, you want to merge them into one prompt, and you really don't want "1girl" appearing twice because your two sources both include it. String Merge Unique (CCN) is the three-line answer - it takes up to three comma-separated strings, merges them, drops duplicates, and keeps the first-occurrence order. One text output, no fuss.

    It's a surprisingly sticky little node once you notice it. Every time you assemble a prompt from parts - base character tags from one place, style from another, a subject block from a third - the overlap problem appears, and hand-deduping is exactly the kind of thing you shouldn't be doing by eye at 1am. This is also a genuinely better fit than a generic "merge" for prompt work specifically, because it preserves order: your most important tags stay in front instead of getting alphabetized or shuffled.

    How it works

    Nothing clever under the hood, and that's a feature. Each input is split on commas, items are whitespace-trimmed, and the merged sequence keeps only the first occurrence of each item. Matching is exact and case-sensitive - 1girl and 1Girl are different items to this node. The result is rejoined with ", " (comma-space) and handed back as text.

    Because it's case-sensitive, "exact" is doing real work here. If your sources differ in capitalization you'll get near-duplicates that look like duplicates and aren't. Worth knowing before you blame the node.

    The inputs and outputs that matter

    • string_1 - required, the first list. One-list input works fine; it just dedupes.
    • string_2, string_3 - optional additional lists to fold in.

    Output: text - the merged, deduped string.

    How to install it

    Standard ComfyCollectorNodes install, shared with every CCN node. ComfyUI Manager → search ComfyCollectorNodes → Install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/valkymaera/ComfyCollectorNodes.git
    

    Restart ComfyUI when it asks. No extra Python dependencies, so no pip step. All nodes in the pack show a (CCN) suffix in the menu.

    Common issues

    The case-sensitivity is the main trap - normalize your tags to one case before merging if your sources aren't consistent. Second, the node handles comma lists, not newline lists; if your sources are line-separated you'll need to get them to comma form first, which its sibling String Replacer can do in one rule.

    And a fair warning about expectations: "unique" here means exact string equality. It won't collapse "masterpiece" and "master piece," and it can't tell that "photo, photography" are semantically the same thing. For deduplicating real prompt tag blocks, though, it does exactly what you'd want it to.

    CategoryComfyCollectorNodes/Utils

    Inputs (3)

    NameTypeDefaultDescription
    string_1STRING
    string_2optSTRING
    string_3optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING