Nodes/comfyui-easyapi-nodes/SplitStringToList
ComfyUI Node

SplitStringToList

Turn one string field into a typed list

By lldacing·Created 3 years ago·Updated 8 months ago· 96
SplitStringToList
    • LIST
    str
    to_typestr
    delimiter,
    methoddelimiter

    Typing five prompts, five seeds, or five URLs into five separate widgets is tedious, and ComfyUI doesn't give you a native "paste a batch, get a list" input. SplitStringToList is the workaround: type (or pipe in) one string, and it comes out the other side as a proper LIST - the type this pack's other list nodes (SliceList, IndexOfList, ListUnWrapper, ForEachOpen) all expect.

    How it works

    Feed it a string and it splits on a delimiter, converting every resulting piece to the type you asked for. "a,b,c" with the default comma delimiter becomes [a, b, c]. The to_type field controls what each element gets cast to - str, int, float, or bool - so a comma-separated list of numbers actually becomes a list of numbers, not a list of number-shaped strings that'll fail type checks downstream.

    The method field (optional, default delimiter) changes how the split point is chosen: delimiter uses whatever string you typed in the delimiter field (comma by default), while LF splits on newlines and tab splits on tab characters. This matters because typing an actual newline into a one-line delimiter text field is awkward - if your source string is multi-line (say, one item per line, pasted from a StringArea node), set method to LF instead of trying to type a newline into the delimiter box.

    Inputs and outputs that matter

    • str (required) - the string to split.
    • to_type (default str) - the target type for each element: str, int, float, or bool.
    • delimiter (default ",") - the separator string, used when method is delimiter.
    • method (optional, default delimiter, tooltip: "how the delimiter is chosen") - pick between the typed delimiter, a literal newline (LF), or a tab.

    Output: a single LIST, ready to wire into any of the pack's list-consuming nodes.

    Installing it

    ComfyUI Manager: search comfyui-easyapi-nodes. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
    cd comfyui-easyapi-nodes
    pip install -r requirements.txt
    

    Restart ComfyUI. No models, no heavy dependencies for this one specifically - it's string-splitting and type-casting.

    Where people get tripped up

    Two real gotchas. First, empty elements: a trailing comma ("a,b,") or a doubled delimiter ("a,,b") will typically produce an empty-string element in the split, and if to_type is int or float, casting an empty string will fail the whole node rather than skipping it - clean your input string (or check it for trailing separators) before it hits this node, especially if it's coming from user input via the API rather than something you typed by hand.

    Second, this is the classic pairing node for StringArea (this pack's multiline text box): write one item per line in StringArea, wire it into SplitStringToList, set method to LF, and you've got a clean multi-item batch input without touching the delimiter field at all. If you instead leave method on delimiter and forget your source string has newlines in it, you'll get one giant single-element list instead of the split you expected - that mismatch between method and the actual string shape is the most common reason this node "does nothing."

    CategoryEasyApi/String

    Inputs (4)

    NameTypeDefaultDescription
    strSTRING
    to_typeCOMBOstr4 options: str, int, float, bool
    delimiterSTRING,
    methodoptCOMBOdelimiter分隔符选取方式

    Outputs (1)

    NameTypeDescription
    LISTLIST