Nodes/ComfyUI-JK-TextTools/String Splitter
ComfyUI Node

String Splitter

Split a delimited string into a typed list — the workhorse of text parsing

By Nakamura2828·Created 8 months ago·Updated 8 months ago· 0
String Splitter
    • list
    • item_count
    textitem1,item2,item3
    delimiter,
    strip_whitespacetrue
    output_type
    remove_emptyfalse

    String Splitter is the most generally useful node in the JK-TextTools text section. It takes a delimited string - "10,25,42,100", a multiline block of prompts, a CSV-ish export - and splits it into a proper list, with the option to cast every item to STRING, INT, or FLOAT along the way. Once it's a typed list, the whole world of ComfyUI list iteration opens up.

    The type casting is what separates it from a dozen other splitter nodes. Split with output_type: INT and you get [10, 25, 42, 100] - actual Python integers, not strings that happen to contain digits. That list can feed an iteration node or a List Index Selector, and the values you pull out plug directly into INT inputs with no conversion node in the middle.

    How it works

    It splits on your delimiter, strips whitespace from each item (on by default), casts per output_type, and - with remove_empty on - drops blank entries. The delimiter understands escape sequences, so typing \n in the field produces real newline splitting, which is how you turn a multiline text box into a list of lines. The output list is flagged OUTPUT_IS_LIST, which is why it shows the grid icon and why downstream nodes iterate over it automatically.

    A note on the output name: it's literally list, not something friendlier - that's just how the pack declares it.

    Inputs and outputs

    • text (STRING) - the string to split.
    • delimiter (STRING, default ,) - what to split on.
    • strip_whitespace (BOOLEAN, default true).
    • output_type (STRING / INT / FLOAT) - cast applied to every item.
    • remove_empty (BOOLEAN, optional, default off).

    Outputs: list (*, list) and item_count (INT).

    Where it fits

    Three patterns cover most use:

    1. Numeric lists - split "10,25,42,100" as INT, iterate or index-select for seeds, frame numbers, resolutions.
    2. Multi-line text - split with \n delimiter, process each line (a prompt per line, a filename per line).
    3. Round-trip with String Joiner - split, transform, re-join into a new delimited string. The pack's own example: split lines, then join with ", " for a comma-separated summary.

    Installing it

    It's part of ComfyUI-JK-TextTools: ComfyUI Manager → search "JK-TextTools" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Nakamura2828/ComfyUI-JK-TextTools.git
    

    Restart ComfyUI. No models to download, no runtime pip dependencies beyond ComfyUI itself.

    Gotchas

    The cast is all-or-nothing: one non-numeric item with output_type: INT raises a ValueError and fails the whole node. With remove_empty off (the default), a trailing delimiter gives you a phantom empty string at the end - it's usually worth switching on. And keep the list output in mind: it's designed to iterate, so if a downstream node misbehaves, check whether you wanted the whole list or one item via List Index Selector.

    CategoryJK-TextTools/string

    Inputs (5)

    NameTypeDefaultDescription
    textSTRINGitem1,item2,item3
    delimiterSTRING,
    strip_whitespaceBOOLEANtrue
    output_typeCOMBO3 options: STRING, INT, FLOAT
    remove_emptyoptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    list*
    item_countINT