ComfyUI Node

TagMerger

Merge two tag strings without duplicating anything

By sugarkwork·Created 2 years ago·Updated 6 months ago· 87
TagMerger
    • result
    tags1
    tags2
    under_scoretrue

    TagMerger does exactly what its name says and no more: combine two comma-separated tag strings into one. The one twist - and it's the whole reason this node exists instead of you using a plain text concat - is that duplicates are silently ignored. Feed it long_hair, smile and smile, blue_eyes and you get long_hair, smile, blue_eyes, not the four-tag mess a naive join would produce.

    That deduplication is order-preserving and per-tag, so it's safe to merge overlapping sets from different branches of your graph without worrying about the same tag being emitted twice (which does nothing helpful to a prompt and looks unprofessional in a workflow dump). This is the utility node of the family - the one you'll wire into your prompt pipeline just to keep it clean, not the one you'll write a blog post about.

    Inputs and the underscore toggle

    • tags1 / tags2 - both optional, both plain STRINGs. Unplugged ports are treated as empty.
    • under_score (default on) - whether the output writes spaces as underscores. With it on, long hair comes out long_hair; off, it stays long hair. Since the pack's category lookup normalizes to underscores internally, keeping this on is usually the right call if the merged output is headed back into another tag node.

    One detail worth knowing: emphasis weights survive the merge. TagMerger uses the same parse_tags machinery as everything else in the pack, so (smile:1.2) from one input stays weighted in the output. It's not a dumb string concat - it's a parse, dedupe, re-serialize.

    How it fits

    The typical shape: you have a "base character" tag set from a tagger and a "dynamic extras" set from a wildcard or random node, and you want one clean string for your text encoder. TagMerger is the join. And because duplicates vanish, it also acts as a cheap "union" operation for your branching prompt logic - if two conditions both contributed smile, you don't end up with smile, smile.

    Where you'd not use it: if you're merging more than two streams, the sibling nodes TagMerger4 and TagMerger6 accept up to four and six inputs and dedupe across all of them at once. Chaining two-input merges works, but the multi-input versions are cleaner and dedupe the whole set in one pass. If you only ever combine two strings, this is your node.

    Install

    Boring, because it's the same pack as everything else on this list: ComfyUI Manager search "comfyui_tag_filter", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/sugarkwork/comfyui_tag_fillter
    

    Restart, and it's under text. No dependencies, no model downloads - the pack's requirements.txt is empty and all the logic lives in one readable nodes.py. About as low-stakes an install as custom nodes get.

    Categorytext

    Inputs (3)

    NameTypeDefaultDescription
    tags1optSTRING
    tags2optSTRING
    under_scoreoptBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    resultSTRING