Nodes/ComfyUI_zfkun/Split Text ๐Ÿ•๐Ÿ…ฉ๐Ÿ…•
ComfyUI Node

Split Text ๐Ÿ•๐Ÿ…ฉ๐Ÿ…•

Turn one block of text into a list you can loop over

By zfkunยทCreated 3 years agoยทUpdated 7 months agoยท 23
Split Text ๐Ÿ•๐Ÿ…ฉ๐Ÿ…•
    • texts
    โ—„textโ€”โ–บ
    โ—„delimiter&โ–บ

    Say you've pasted in ten prompt variations, one per line, or a comma-separated pile of tags, and you want ComfyUI to treat that as ten separate strings rather than one giant blob - feeding a batch of CLIP Text Encodes, or driving a loop that generates one image per line. That's what Split Text does: give it a block of text and a delimiter, and it hands back a list, ready to plug into anything downstream that expects list-mode input.

    How it works

    Straightforward string splitting - cut the input on every occurrence of the delimiter, output the pieces as a list. The mechanism is nothing exotic; the value is that it produces a genuine ComfyUI list output, which is what turns "one blob of text" into "N things ComfyUI will iterate over" for any node built to consume a list.

    The inputs and outputs that matter

    Only two inputs, and both matter:

    • text (required, multiline STRING) - the block you're splitting. Paste in your multi-line or delimiter-separated content here.
    • delimiter (required, STRING, default &) - what to split on. The default is &, which is an odd choice for prose but fine for short tag-style entries; for anything resembling actual sentences you'll almost certainly want to change it to a newline, comma, or |, whatever matches how you actually formatted your text block.

    Output: texts, a proper list (is_list: true) - wire it into anything downstream that's built to run per-item, such as this pack's own Preview Text (List) to sanity-check the split, or a batch of prompt-consuming nodes further along.

    How to install it

    Via ComfyUI Manager: search "ComfyUI_zfkun", install, restart. Manually:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/zfkun/ComfyUI_zfkun
    pip install -r requirements.txt
    

    then restart. No models, no extra config - this is pure string handling.

    Common issues & troubleshooting

    Nothing seems to split - you get one giant item back. Check that delimiter actually matches what's in your text. The default is &; if your text is separated by commas or newlines and you left the delimiter untouched, you'll get exactly one "split" item containing the whole block.

    You want to split on a newline and can't type one into the field. A literal newline is awkward to enter in a single-line delimiter widget in some browsers/OSes. If that's biting you, reformat your source text to use a simple single-character delimiter like , or | instead - much less friction than fighting a text field for a newline character.

    Downstream node doesn't seem to be receiving multiple items. Confirm the node you're feeding is actually built for list-mode input - not every ComfyUI node is. If it only expects a single STRING, it'll typically just take the first item or error, not iterate. This pack's own Preview Text (List) is the easiest way to confirm your split actually produced the list you think it did, before you chase the problem further downstream.

    Empty entries after splitting. A trailing delimiter (text ending in your delimiter character) or two delimiters in a row will produce empty strings in the list. Worth a quick eyeball in Preview Text (List) if your downstream count looks off by one.

    Categoryzfkun ๐Ÿ•๐Ÿ…ฉ๐Ÿ…•

    Inputs (2)

    NameTypeDefaultDescription
    textSTRINGOriginal texts content to be split
    delimiterSTRING&Separator

    Outputs (1)

    NameTypeDescription
    textsSTRINGโ€”