Nodes/comfyui_LLM_Polymath/Split Texts by Specified Delimiter
ComfyUI Node

Split Texts by Specified Delimiter

Turn one big text blob into a list, then do something with each piece

By lum3on·Created 2 years ago·Updated 6 months ago· 75
Split Texts by Specified Delimiter
    • splitted_texts
    input_string
    delimiter\n
    ignore_before_equalsfalse

    Split Texts by Specified Delimiter does exactly what its display name says: it takes one string, chops it on a delimiter you pick, and hands you back a list of strings. It's the smallest node in the comfyui_LLM_Polymath pack and also one of the most quietly useful, because ComfyUI is weirdly bad at "I have a big blob of text and I want to process it line by line."

    Why you'd reach for it

    Any time you have a multi-line prompt source and want to treat each line as its own unit. The classic pattern in this pack's own example workflows: a batch of prompts, one per line, gets split, then each chunk is fed individually into the polymath_chat node or piped into a picker so you can grab one line at a time. It's also handy for CSV-ish output from a model - split on , and you've got a clean list of tags or concepts.

    How it works

    Under the hood it's one split() call with two conveniences bolted on. The first: the delimiter field defaults to the literal string \n, and the node quietly converts that to a real newline for you - so the default behavior is "split on newlines," which is what 90% of people want, without you having to understand escaped characters. The second is ignore_before_equals: when enabled, any line that contains an = gets trimmed to everything after the first =. That's made for key=value output. Feed it:

    width=512
    height=512
    prompt=a cat
    

    and with ignore_before_equals on you get 512, 512, a cat - clean values, no key noise. Each part is also stripped of surrounding whitespace, so you don't get stray blank entries from trailing newlines.

    Inputs and outputs

    Only three inputs, and you'll rarely touch two of them:

    • input_string - the text to split. This is force-input only, so you can't type into it; it has to come from another node. That's fine, it's the point.
    • delimiter - default \n. Change it to ,, |, or any separator your data uses.
    • ignore_before_equals - default off. Flip it on for key=value parsing as above.

    Output: splitted_texts, a STRING list. Wire it into the list_input of the pack's polymath_StringListPicker to select one element, or into any node that accepts a string list (some chat/LLM nodes iterate over lists natively).

    Installation

    It ships inside comfyui_LLM_Polymath - install that pack via ComfyUI Manager (search "comfyui_LLM_Polymath") or cd ComfyUI/custom_nodes && git clone https://github.com/lum3on/comfyui_LLM_Polymath, run pip install -r requirements.txt, restart. That install is heavy (the pack pulls easyocr, jax, gallery-dl and friends for its other nodes) but this node itself uses nothing but Python's str.split, so it works even if some of the pack's fancier nodes failed to import.

    Troubleshooting

    The two things that trip people up: if your delimiter is a real newline typed into a multiline field, it won't match - use \n as the delimiter (the pack handles that special case for you). And if you expected splitting on commas but the string used full-width or different punctuation, check what your upstream node is actually emitting with a ShowText first. Not a glamorous node - but it's the kind of utility that saves you from writing your own string-processing mini-node for the hundredth time.

    CategoryPolymath/helper

    Inputs (3)

    NameTypeDefaultDescription
    input_stringSTRING
    delimiterSTRING\n
    ignore_before_equalsBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    splitted_textsSTRING