ComfyUI Node

Split List

Cut a list in two at any index — the batch-split you keep needing

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
Split List
    • first_part
    • second_part
    input_list
    split_index1

    The simplest version of this idea is boring: take a list, cut it at an index, get two lists. But "split a batch in two" is one of those operations you keep wanting in ComfyUI and keep not finding, because core nodes are allergic to producing two lists from one input. Split List does exactly that, with predictable, easy-to-reason-about behavior.

    How it works

    Two inputs, two outputs. Feed in input_list (again, a genuine ComfyUI list - it's marked forceInput, so you wire it from a list node rather than typing into a box) and set split_index (an INT, default 1, minimum 0).

    Out the other side you get first_part and second_part, both string lists. The cut is a clean Python slice:

    • first_part = items from the start up to split_index
    • second_part = everything from split_index onward

    So an index of 2 on ["a", "b", "c", "d"] gives you ["a", "b"] and ["c", "d"]. There's no clipping drama: an index of 0 returns an empty first part and the whole list as the second; an index beyond the length returns the whole list as the first part and an empty second. No errors, just empties - which makes it safe to drive from a computed index.

    Where you'd use it

    The obvious case is splitting a batch of prompts, filenames, or images into two halves and treating them differently. First ten prompts get a LoRA, the rest don't. First half of a frame list goes through a different sampler. Or use it as a poor-man's "first item" extractor: split at index 1 and grab the first part, which is just that single entry.

    It's part of TinyBee's list family, so it pairs with String To List (to create the list), Sort List (to order it first), and Indexed Entry / Random Entry (to pull items out of one of the halves).

    Install

    This node ships in the ComfyUI-TinyBee pack. ComfyUI Manager: search ComfyUI-TinyBee, install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    Restart ComfyUI and it's under 🐝TinyBee/Lists. Pure stdlib - the pack's pillow/jsonata requirements don't touch this node.

    Gotchas

    Two things trip people up. First, input_list is a list input, not a text field - if you type comma-separated text into a string widget, this node will error with "Input must be a list." Run the text through String To List first. Second, remember the index is where the cut happens, not a count of how many items you want in the first part - which is the same thing only when the index lands at the end of a block. Off-by-one confusion is real here; mentally check it against a tiny example before wiring it into something important.

    Category🐝TinyBee/Lists

    Inputs (2)

    NameTypeDefaultDescription
    input_listSTRING
    split_indexINT1

    Outputs (2)

    NameTypeDescription
    first_partSTRING
    second_partSTRING