Nodes/Basic data handling/splitlines (to LIST)
ComfyUI Node

splitlines (to LIST)

Splitlines as One LIST You Can Manipulate as a Unit

By StableLlama·Created about a year ago·Updated 4 days ago· 48
splitlines (to LIST)
    • LIST
    string
    keependsfalse

    This is the other half of the splitlines pair, and picking between them is the whole game. splitlines (to LIST) takes a multi-line string, breaks it at line boundaries, and hands you back a single Python LIST variable - not the per-item stream the sibling node produces. Same split, different container, and the container decides what you can do next.

    Data list vs. LIST, in one paragraph

    The Basic data handling pack draws a line that trips people up constantly. A data list is ComfyUI's native list type: each element is processed individually as it flows through the graph, which is what you want for "render each prompt separately." A LIST is a Python list passed around as one value - the whole collection arrives at once, keeps its order and duplicates, and supports index-based access. That's this node. If your downstream step needs to handle the lines as a batch (sort them, index into them, feed the whole thing to something that takes a LIST), you want this variant.

    How it works

    The mechanism is the same as its sibling: Python's str.splitlines(), which handles \n, \r\n, and other Unicode line boundaries. It's part of StableLlama's Basic data handling pack, a zero-dependency collection of plain-Python utilities, so there's no model download or dependency install anywhere in the story.

    Inputs are string (required, the blob you're splitting) and the optional keepends toggle (default false). Set keepends to true and the line breaks are kept on each item. The output is named LIST, and it's one Python list of strings. From there you can wire it into the pack's LIST manipulation nodes - length, get item, sort, reverse, slice - or a StringListJoin if you want to reassemble the text differently.

    Why you'd reach for it

    The "manipulate as a unit" phrasing isn't abstract. Concrete cases:

    • You split a document, then want to join it back together with a different separator - that's a LIST workflow.
    • You need to count or index lines, or sort them before use.
    • You're collecting lines from several sources and want to merge them into one list for a downstream tool that expects a single variable.

    If instead you want each line rendered separately through the rest of the graph - batch generation, per-line prompt processing - the data list version is the right tool and this one will fight you. When in doubt, remember the README's own framing: individual processing → data list, whole-collection handling → LIST.

    Installing it

    Same as the rest of the pack - search "Basic data handling" in ComfyUI Manager and restart, or:

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

    Restart ComfyUI and you're done. No dependencies, no extra files. The only real source of confusion is choosing the wrong splitlines variant for your graph - the wire types (data list STRING vs. LIST) don't match each other, so the mistake announces itself as a connection error.

    CategoryBasic/STRING

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    keependsoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    LISTLIST