Nodes/ComfyUI-TinyBee/String Combiner
ComfyUI Node

String Combiner

The prompt-variation node that does the cartesian product for you

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
String Combiner
    • combined_string
    • index
    • total_combos
    num_lists2
    template%1, %2
    index0
    list_1
    list_2
    list_3
    list_4
    list_5
    list_6
    list_7
    list_8
    list_9
    list_10

    If this pack had one node I'd call a sleeper hit, it's String Combiner. It takes up to ten lists of strings, generates every combination across them, and serves them up one at a time through a single template. It's the thing you'd otherwise build with a spreadsheet, and it does it natively in the graph.

    How it works

    Three controls and up to ten inputs. Set num_lists (1–10, default 2) to choose how many of the list_1 through list_10 slots are active, wire your lists in, and write a template using %1, %2, … placeholders. Default template is %1, %2. The index input (default 0) picks which combination comes out.

    Under the hood it's a cartesian product: with a 3-item list and a 4-item list, you get 12 total combinations. The math is:

    • total_combos (an output) = product of all list lengths
    • index selects which combo, computed so that the last list varies fastest
    • set index to -1 and it picks a random combination each run

    You get three outputs: combined_string (the rendered template), index (the combo that was actually used - useful when you picked -1), and total_combos.

    Why that's useful

    This is the missing link for prompt sweeps. Feed it a list of subjects and a list of styles, wire combined_string into a CLIP Text Encode, drive index from an incrementing node, and ComfyUI grinds through every subject×style pairing in order. Raise num_lists to three or four and you're doing real factorial-style experimentation without writing a single Python node. If you've ever batched "how would this look in every style," this node is your answer.

    Install

    Part of ComfyUI-TinyBee. ComfyUI Manager → search ComfyUI-TinyBee → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    It appears under 🐝TinyBee/Strings. Pure stdlib; no models, no extra dependencies.

    Gotchas

    The template replacement is literal: placeholders are %1%N and each is replaced with the string at that position in the combination. The node also always reports itself as changed, so it re-renders every execution rather than caching. One trap: the index output after a -1 (random) pick is the actual chosen combo, which is what you want if you need to reproduce it. And if a list is empty, its slot contributes nothing to the combination but also nothing to the count - an empty list makes that position render as an empty string while total_combos still multiplies by 1. Keep your lists non-empty and the behavior is predictable.

    Category🐝TinyBee/Strings

    Inputs (13)

    NameTypeDefaultDescription
    num_listsINT21–10
    templateSTRING%1, %2
    indexINT0-1–2147483647
    list_1optSTRING
    list_2optSTRING
    list_3optSTRING
    list_4optSTRING
    list_5optSTRING
    list_6optSTRING
    list_7optSTRING
    list_8optSTRING
    list_9optSTRING
    list_10optSTRING

    Outputs (3)

    NameTypeDescription
    combined_stringSTRING
    indexINT
    total_combosINT