ComfyUI Node

Split String

Turn one text box into a batch of prompts, seeds, or filenames

By godmt·Created 2 years ago·Updated about a month ago· 16
Split String
    • STRING
    • PYLIST
    • length
    STRING
    delimiter,
    splitlinesfalse
    stripfalse

    Most people hit this node the same way: they've got a text box full of prompt variants, one per line, and they want ComfyUI to run each one separately instead of pasting them in one at a time. Split String is the node for that. Type or paste multiline text in, get a ComfyUI List out, and every downstream node runs once per line - same graph, no copy-pasting, no manual re-queuing.

    How it works

    You give it text and two ways to cut it up. splitlines breaks the input on newlines first. delimiter then splits within whatever you're left with - so with splitlines on and a comma delimiter, a three-line box where each line has two comma-separated tags gives you six items total, not three. Turn splitlines off and it's a flat delimiter split of the whole blob, newlines and all. Either way, empty items get dropped automatically, so a trailing blank line or a double comma won't hand you an empty string entry to trip on later.

    The inputs and outputs that matter

    • STRING - the text box itself, multiline. This is the whole input; everything else just controls how it's cut.
    • delimiter (default ,) - what splits each chunk. Leave it empty if you only want line-based splitting.
    • splitlines (default off) - split into lines before applying the delimiter. Turn this on for one-prompt-per-line text.
    • strip (default off) - trims whitespace off each resulting item. Worth turning on if you're pasting from somewhere that leaves trailing spaces, since a stray space can change how some models read a prompt.

    Three outputs, and picking the right one matters: STRING is a ComfyUI List - wire it straight into a prompt/seed/filename input and the graph runs once per item. PYLIST is the same data as one raw Python array value, for when you want to count it, slice it, or feed it to Exec without triggering List processing. length just tells you how many items came out, handy for a progress display or a sanity check that your split actually did what you expected.

    How to install it

    Easiest path is ComfyUI Manager: open it, search "ComfyUI-List-Utils", install, restart. Manually, it's a plain clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/godmt/ComfyUI-List-Utils.git
    

    Restart ComfyUI and the whole pack shows up under the list_utils category. There's nothing to download - no models, no weights, no heavyweight Python dependencies. It's pure standard-library string splitting, so this is about as low-risk an install as a custom node gets.

    Common issues & troubleshooting

    "It only ran once instead of looping." You almost certainly wired the PYLIST output somewhere that expected the STRING List output, or vice versa. This pack draws a hard line between "ComfyUI List" (triggers per-item execution) and "PyList" (one Python value, no looping) - the README calls this out as the single most common point of confusion in the whole pack. If a connection isn't doing what you expect, that's the first thing to check, and List To PyList / PyList To List exist specifically to convert between the two when you get it backwards.

    Got fewer items than expected. Empty items are silently removed - that's deliberate, not a bug, so a text box with a blank line in the middle won't hand you an empty-string run. If you actually need to preserve blanks (rare, but it happens with positional data), this node isn't going to do it; you'd want a different splitting approach.

    Items have stray whitespace or quote marks baked in. Turn on strip. It won't strip surrounding quotes, just leading/trailing whitespace, so if your source text wraps entries in quotes you'll need to clean that upstream or downstream with a string-replace node.

    Categorylist_utils

    Inputs (4)

    NameTypeDefaultDescription
    STRINGSTRINGText to split. Multiline text is supported.
    delimiterSTRING,Delimiter used inside each line. Leave empty to skip delimiter splitting.
    splitlinesBOOLEANfalseSplit the input into lines before applying the delimiter.
    stripBOOLEANfalseTrim leading and trailing whitespace from each item.

    Outputs (3)

    NameTypeDescription
    STRINGSTRINGSplit items as a ComfyUI List-processing output.
    PYLISTPYLISTSplit items as one raw Python list value.
    lengthINTNumber of split items.