ComfyUI Node

XStringGroup

Five prompts in, one out — switch style variants without rewiring anything

By Xz3r0-M·Created 8 months ago·Updated about 9 hours ago· 13
XStringGroup
    • total_string
    • selected_string
    • string_1
    • string_2
    • string_3
    • string_4
    • string_5
    select_string1
    string_1
    separation_method_1_2none
    string_2
    separation_method_2_3none
    string_3
    separation_method_3_4none
    string_4
    separation_method_4_5none
    string_5
    none_on_emptytrue

    Prompts in ComfyUI tend to accumulate in ugly ways: a CLIP Text Encode for the subject, a second one for the style, a third for the negative, and suddenly the workflow is a tangle of text boxes and reroutes. XStringGroup takes a different approach - up to five multiline strings in one node, with a separator of your choice between each, and it hands you back both the combined result and whichever single string you select.

    The killer feature is the selector. You can park five different style variants (or five negative-prompt candidates) in one node and flip between them with a dropdown instead of pasting text around the graph. That's a workflow-level A/B test without touching any connections.

    How it works

    It's a dumb concatenator with guard rails. Each pair of strings gets a separation_method combo: none, newline, space, comma, comma_space, period, or period_space. The node joins string_1 through string_5 in order with the chosen separators between them - no clever merging, just exact concatenation with exactly the separator you picked.

    select_string is a combo from "1" to "5" that picks which input gets passed through as selected_string. The node validates the selection rather than crashing on a bad index, which is the kind of thing you only appreciate when a shared workflow hands it a stale value.

    The inputs that matter

    • select_string - the dropdown that chooses which of the five strings becomes selected_string.
    • string_1 … string_5 - the five multiline inputs.
    • separation_method_1_2 … separation_method_4_5 - the joiner between each adjacent pair. If you only use two strings, leave the later methods at "none" and they'll contribute nothing.

    The outputs

    Seven of them, which is a lot, but only two really matter:

    • total_string - all five joined with their separators. This is what feeds your CLIP Text Encode for the positive prompt.
    • selected_string - whichever one you picked with the selector.
    • string_1 … string_5 - pass-through copies of each original input, so you can route one of them elsewhere without adding reroutes.

    A common pattern: string_1 holds the subject, string_2 the style, string_3 quality tags, with comma_space between them, and total_string becomes "subject, style, quality". Then a second XStringGroup or a switch selects between three negative prompts for testing.

    Installing

    Ships in ComfyUI-Xz3r0-Nodes. ComfyUI Manager → search "ComfyUI-Xz3r0-Nodes" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Xz3r0-M/ComfyUI-Xz3r0-Nodes.git
    cd ComfyUI-Xz3r0-Nodes
    pip install -r requirements.txt
    

    Restart ComfyUI. No models to fetch; the only Python dependency in the pack is ffmpeg-python and this node never touches it.

    Gotchas

    • The separators are exact. "comma" gives , with no space; "comma_space" gives , . Mixing them up is the #1 way to get prompts that read like dog,cat,bird when you meant dog, cat, bird.
    • select_string only changes selected_string - total_string always contains all five, so empty slots contribute empty text (plus whatever separator precedes them). If string_2 is empty and the 1_2 separator is "space," you get a leading space. Set unused separators to "none" to avoid stray junk.
    • The original inputs all pass through as outputs, so it doubles as a small organizer even if you never use total_string.
    Category♾️ Xz3r0/Workflow-Processing

    Inputs (11)

    NameTypeDefaultDescription
    select_stringCOMBO1Select which string to output (1-5)
    string_1STRINGFirst multiline string input
    separation_method_1_2COMBOnoneSeparation method between String 1 and String 2 (none: '', newline: \n, space: ' ', comma: ',', comma_space: ', ', period: '.', period_space: '. ')
    string_2STRINGSecond multiline string input
    separation_method_2_3COMBOnoneSeparation method between String 2 and String 3 (none: '', newline: \n, space: ' ', comma: ',', comma_space: ', ', period: '.', period_space: '. ')
    string_3STRINGThird multiline string input
    separation_method_3_4COMBOnoneSeparation method between String 3 and String 4 (none: '', newline: \n, space: ' ', comma: ',', comma_space: ', ', period: '.', period_space: '. ')
    string_4STRINGFourth multiline string input
    separation_method_4_5COMBOnoneSeparation method between String 4 and String 5 (none: '', newline: \n, space: ' ', comma: ',', comma_space: ', ', period: '.', period_space: '. ')
    string_5STRINGFifth multiline string input
    none_on_emptyBOOLEANtrueWhen enabled, output None if all strings are empty; when disabled, output empty string instead

    Outputs (7)

    NameTypeDescription
    total_stringSTRINGOutput of all grouped strings (with separation methods)
    selected_stringSTRINGSelected string output based on select_string
    string_1STRINGOriginal output of String 1
    string_2STRINGOriginal output of String 2
    string_3STRINGOriginal output of String 3
    string_4STRINGOriginal output of String 4
    string_5STRINGOriginal output of String 5