ComfyUI Node

Merge Tag

Merge Tag stitches up to four tag strings together — order be damned

By AiMiDi·Created 2 years ago·Updated 2 years ago· 0
Merge Tag
    • STRING
    tag_text_a
    tag_text_b
    tag_text_c
    tag_text_d

    Merge Tag combines up to four comma-separated tag strings into one, deduplicated. It's the node you use when your tags come from more than one place and you need them in a single string: a WD14 tagger output in one input, a hand-written style block in another, a fixed character tag in a third. Feed it whatever's available, get one clean prompt string out.

    Where this shines is caption assembly - and the caption side of the pair matters more than people admit. The lora-training knowledge base hammers the same point: for Illustrious/Pony/NoobAI you caption with comma-separated Danbooru tags, and merging a tagger's output with your own additions is exactly that workflow. It's also handy at inference time, letting you keep a "base tags" string and an "experiment tags" string separate in the graph, then fuse them before the sampler - which is much easier to reason about than one giant prompt box you keep editing.

    How it works - and the gotcha

    The node takes whatever inputs are connected (tag_text_a through tag_text_d), splits each on commas, trims whitespace, and then does something you need to know about: it collapses the results through a Python set, which means duplicates are removed and order is not preserved. Output order is effectively arbitrary.

    That's fine for most use cases - deduplication is a feature, and on SDXL-lineage models tag order only strongly matters for the first few tags. But it means this is the wrong tool if you're relying on ordering to push quality tags to the front. If ordering matters, merge first and then run Move Tag To Top from this same pack to hoist the tags you care about. Don't ask Merge Tag to do it, because it can't.

    Inputs and output

    • tag_text_a / tag_text_b / tag_text_c / tag_text_d (all optional): the tag strings to merge. Any that aren't connected are simply ignored, so you can build chains that use one, two, or four inputs.
    • STRING output: the merged, deduplicated tag string. Feed it to your positive prompt, or to Save Images Pair if you're writing captions out to a dataset.

    One practical note: each input can itself hold multiple comma-separated tags - the merge happens across all of them, not per-input.

    Installing it

    Same drill as every node in this pack: no requirements.txt, no model downloads, nothing beyond what ComfyUI already bundles. The README is empty (title only), so the source is the truth, and it's tiny. Via ComfyUI Manager, search ComfyUI-Aimidi-nodes; manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AiMiDi/ComfyUI-Aimidi-nodes
    

    Restart ComfyUI and watch for the blue ComfyUI Aimidi Nodes: Loaded line.

    Common issues

    Two real-world traps. First, the order thing - if your merged output looks "scrambled," that's the set, not a bug. Second: if an input is wired but appears ignored, check that the connection actually carries a string; empty strings merge to nothing. And as with all the tag nodes, comma separation is assumed - a single newline-separated block will be treated as one tag.

    CategoryAimidi Nodes

    Inputs (4)

    NameTypeDefaultDescription
    tag_text_aoptSTRING
    tag_text_boptSTRING
    tag_text_coptSTRING
    tag_text_doptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING