Nodes/Basic data handling/split (to data list)
ComfyUI Node

split (to data list)

Split (to data list) — one string in, a pile of parts out, each processed

By StableLlama·Created about a year ago·Updated about 18 hours ago· 48
split (to data list)
    • STRING
    string
    sep
    maxsplit-1

    This is the workhorse of text parsing in ComfyUI: split (to data list) cuts a string into parts at a separator and hands them out as a native data list, where each part becomes an individual value ComfyUI can process on its own. Turn a comma-separated prompt into separate tags, break a line of data into fields, or explode a sentence into words - then feed each part into whatever per-item nodes come next.

    The name says it all: it's split, and it outputs a data list (native ComfyUI batch of individual strings), not a LIST variable. That distinction is the whole reason the pack ships a separate rsplit/split family - you pick the container that matches what your graph expects next.

    How it works

    Python's str.split(sep, maxsplit), splitting from the left. Two behaviors matter:

    • Empty sep (the default) means whitespace splitting: any run of whitespace is a separator, and consecutive whitespace collapses - "a b\tc"["a", "b", "c"], never empty tokens.
    • An explicit sep like "," splits on that exact string and keeps empty tokens: "a,,b".split(",")["a", "", "b"].
    • maxsplit defaults to -1 (no limit). Set it to split only the first N separators.

    Inputs and outputs

    • string - required, the text to split.
    • sep - optional STRING, default "". Empty = whitespace splitting; otherwise the literal separator.
    • maxsplit - optional INT, default -1. Max number of splits from the left.

    Output is a data list of STRING - each part is an individual value, so the output plugs directly into per-item nodes and ComfyUI processes the parts one at a time.

    Installing it

    Ships in the Basic data handling pack by StableLlama. ComfyUI Manager, search "Basic data handling", install, restart. Manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Pure Python, zero dependencies, no downloads - installs clean, which is why the pack shows up inside shared workflows without an install saga. Under Basic/STRING in the menu.

    Common issues

    The two separator modes trip everyone once. With sep empty, whitespace splitting is forgiving (collapses runs, no empties). The moment you set an explicit sep, you've opted into strict CSV-style behavior where "a,,b" produces an empty middle element - filter it out if you don't want it. maxsplit also splits from the left, so split(",", 1) gives you ["first field", "the entire rest"], not the tail - that's what rsplit is for. And don't forget the output is a data list: if you wanted the parts as one LIST variable to process as a whole, this pack has the LIST-variant split for that. Pick by what your downstream node actually consumes.

    CategoryBasic/STRING

    Inputs (3)

    NameTypeDefaultDescription
    stringSTRING
    sepoptSTRING
    maxsplitoptINT-1

    Outputs (1)

    NameTypeDescription
    STRINGSTRING