ComfyUI Node

Tag Alternating Combiner

Interleave tag sets instead of stacking them

By NMWave·Created 2 years ago·Updated 6 months ago· 6
Tag Alternating Combiner
    • STRING
    tag_field1
    tag_field2
    tag_delimiter,
    tag_field3_opt
    tag_field4_opt
    tag_field5_opt

    Most of the time you merge two tag lists by gluing them end to end: all of field A, then all of field B. Tag Alternating Combiner does something weirder and occasionally much more useful - it interleaves them proportionally. If field one has 20 tags and field two has 5, it takes 4 from field one, then 1 from field two, and repeats. The result is a single prompt where both sources stay evenly represented from start to finish instead of one dominating the front of the string.

    Why would you want that? Prompt order matters on Danbooru-trained models, and a long run of one category can push the whole prompt's emphasis in one direction. If you're merging a character tag set with a scene/action set and you want the model to treat them as co-equal throughout, proportional interleaving gives you a more balanced mix than a block dump. It's also a neat way to force variety when you're combining wildcard-expanded pools.

    How it works

    The node computes each field's share of the total tag count as a ratio, then walks all fields in round-robin rounds, pulling round(ratio × rounds) tags per field per round. Any leftovers - the parts that don't fit evenly into the interleave - get appended at the end, so nothing is ever dropped.

    Two required inputs, three optional:

    • tag_field1, tag_field2 - the two main tag lists (string, wired in or typed).
    • tag_delimiter - separator, default , .
    • tag_field3_opt, tag_field4_opt, tag_field5_opt - up to three more sources you can mix in. Empty ones are simply skipped, so it degrades gracefully to a two-way combiner.

    One STRING output, ready for your prompt encode.

    Install

    Same pack as the rest: ComfyUI Manager → "Nader Tagging" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/NMWave/ComfyUI-Nader-Tagging
    

    No dependencies, no models.

    The honest caveats

    The exact interleave pattern is a side effect of the ratio math, not something you tune directly. With 20 vs 5 tags you get the clean "4 then 1" the README advertises, but with awkward ratios like 13 vs 7 the pattern gets lumpy - and lumpy is fine, it's still proportional. Just don't expect a perfectly strict 1-1 alternation; this is a ratio mixer, not a zip.

    Two things to keep in mind:

    • Order of the final string is fully deterministic for the same inputs - good for reproducible batches, but you'll want to randomize upstream if you're using this for variation.
    • Trailing leftovers always land at the end, so with very uneven fields the tail of your prompt is all from the bigger source. If that bugs you, trim the fields first with Split Tags.

    It's a niche tool - most people won't need it, and that's fine. But when you're building batch-generation rigs that merge multiple prompt sources, it's the difference between a prompt that reads like two paragraphs stapled together and one that reads like it was mixed on purpose.

    CategoryNMWave/text

    Inputs (6)

    NameTypeDefaultDescription
    tag_field1STRING
    tag_field2STRING
    tag_delimiterSTRING,
    tag_field3_optoptSTRING
    tag_field4_optoptSTRING
    tag_field5_optoptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING