Nodes/lzits Nodes/String Splitter
ComfyUI Node

String Splitter

One prompt in, a batch of prompts out

By lzitser23·Created 9 months ago·Updated 3 months ago· 0
String Splitter
    • STRING
    text
    delimiter,

    ComfyUI loves batches, but your prompt text is usually one block. String Splitter turns a single multi-line or comma-separated string into a list of strings - the standard way to feed a batch workflow with a bunch of prompt variations.

    How it works

    You give it text and a delimiter, and it splits, strips whitespace from each piece, and drops empty entries. The docstring's example is the whole story: "A cat, A dog" becomes a batch of two prompts.

    A couple of details from the source worth knowing:

    • Type \n (as the two literal characters) in the delimiter and it's interpreted as a real newline - that's how you split a multi-line prompt list.
    • An empty delimiter returns the text unsplit, as a one-element list, rather than erroring.
    • The output is a STRING list - it sets OUTPUT_IS_LIST = True.

    Inputs and output

    • text (STRING, multiline) - the block to split.
    • delimiter (STRING) - default ,.

    Output: a STRING list.

    The catch that trips everyone up

    A list output means whatever you connect downstream gets iterated: most nodes that accept a string will run once per element, which is the batch behavior you probably wanted. But if you only want one element - say, to test one prompt out of twenty - a plain wire will process all of them. That's what this pack's Index Picker is for: connect the splitter's list to it, pick an index, get a single string.

    Another subtlety: this is not a "split into individual prompts by newline" magic wand unless you set the delimiter to \n. Default comma-splitting a multi-line block with commas in your sentences will mangle it - set the delimiter to match how your text is actually structured.

    Installing this node

    One of the 16 nodes in the lzits Nodes pack (Lior Zitser, MIT). Install via ComfyUI Manager (search "lzits Nodes") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lzitser23/lzits-nodes.git
    

    Restart ComfyUI. No dependencies.

    Categorylzits nodes

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    delimiterSTRING,

    Outputs (1)

    NameTypeDescription
    STRINGSTRING