Nodes/ComfyUI-YogurtNodes/StringSplit (Yogurt Nodes)
ComfyUI Node

StringSplit (Yogurt Nodes)

Turn one comma-separated text blob into a real list

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
StringSplit (Yogurt Nodes)
    • list_result
    text
    separator,
    max_split-1
    strip_itemstrue

    ComfyUI has a weird habit of forcing you to treat text as one long string when your actual intent is "a list of things." You paste red, blue, green and half the graph wants a list it can index, iterate, and filter. YogurtStringSplit is the bridge: it takes a string, cuts it on a separator, and outputs a genuine list that the pack's list nodes - and most anything else that accepts a * input - can consume.

    What it does

    The node's own tooltip is refreshingly direct: "Split a string into a list." The required text input is what you're cutting. Then three optional knobs:

    • separator (default ,) - what to split on. And here's a nice touch: leave it empty and the node splits on every character, so "abc" becomes ["a", "b", "c"].
    • max_split (default -1) - cap on the number of splits. -1 means no limit; set it to 2 to keep the rest of the string intact as the final element.
    • strip_items (default true) - trims whitespace off each piece, so "red, blue" doesn't give you ["red", " blue"].

    One output: list_result, typed *. If you're splitting a comma list, you can wire that straight into YogurtListIndex, YogurtListLength, or feed each element into a YogurtStringToValue for typed values.

    Why you'd reach for it

    Realistic ComfyUI use: LoRA lists. You keep my_lora_v1, my_lora_v2, my_lora_v3 in a text box, split it, and loop or batch over the elements. Or parse the filename patterns that the pack's Glob Files node returns - those come back as a list already, but sometimes you get a single path string with commas and want it exploded. It also pairs naturally with YogurtToList: split gives you list-shaped data, ToList coerces anything iterable to a proper Python list when a downstream node is picky about types.

    The * output type is both the strength and the caveat. It'll connect to almost anything, which is great, but it means the node can't protect you from a downstream node that turns out to want a different shape. When in doubt, follow it with YogurtToList to normalize.

    Installing it

    It ships in the Yogurt Nodes pack under YogurtNodes/Logic. One install, all nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
    cd ComfyUI-YogurtNodes
    pip install -r requirements.txt
    

    Or search "ComfyUI-YogurtNodes" in ComfyUI Manager. Restart after. No models, no API keys.

    Common issues

    The separator is literal, not a regex. If your text has a|b|c and you split on |, fine - but don't expect | to be treated as an alternation the way it would be in a regex node. And watch the empty-separator footgun: leaving separator blank doesn't mean "no split," it means "split every character." If your output is suddenly a list of single letters, that's exactly what happened. If that's not what you wanted, put a real separator in there.

    CategoryYogurtNodes/Logic

    Inputs (4)

    NameTypeDefaultDescription
    textSTRINGText to split
    separatoroptSTRING,Separator to split on (empty string splits every character)
    max_splitoptINT-1Maximum number of splits (-1 for no limit)
    strip_itemsoptBOOLEANtrueStrip whitespace from each item

    Outputs (1)

    NameTypeDescription
    list_result*