Nodes/qq-nodes-comfyui/Text Splitter
ComfyUI Node

Text Splitter

Turn one string into a list, commas and all — just watch the whitespace

By kenjiqq·Created 3 years ago·Updated about a year ago· 76
Text Splitter
    • LIST
    text
    delimiter,

    Text Splitter is the string-to-list bridge in kenjiqq's pack: feed it a text block and a delimiter, get back a LIST with the text chopped into pieces. It's the fastest way to throw five prompts at XY Grid Helper without setting up a file, and it's the node people usually reach for first when they discover the pack - hence the search traffic.

    What it does is dead simple, but there's one behavior that will absolutely bite you, and it's the whole article.

    How it works

    • text - a STRING, type it in or wire it in.
    • delimiter - the split character, default ,.
    • LIST - the output: text.split(delimiter), one element per piece.

    The implementation is literally Python's str.split(). Input "sunset, city, neon" with delimiter ,["sunset", " city", " neon"]. Then wire the LIST into row_list or column_list on XY Grid Helper, or into Any List Iterator if you want to step through it.

    The gotcha: whitespace is not trimmed

    Python's split() does exactly what you say and nothing else. Split on , and a space after the comma stays attached to the front of the next item. So the innocent-looking "alpha, beta, gamma" gives you "alpha", " beta", " gamma" - with leading spaces.

    That usually doesn't matter for prompts, because CLIP Text Encode will strip them. But it does matter when:

    • The pieces go into something exact-match, like a sampler or checkpoint name dropdown built from the text.
    • You compare the strings downstream.
    • You're puzzled why one grid row "looks different" from the others - a leading space can change how a model reads a prompt tag.

    Fix it the boring way: no spaces after your delimiters ("alpha,beta,gamma"), or run the output through a text-trimming node. The README's own suggestion for converting these strings into other types is to pass them through an Axis To STRING converter and then WAS Node Suite nodes.

    Two more behaviors worth knowing

    • Consecutive delimiters make empty strings. "a,,b"["a", "", "b"], and an empty prompt in a grid is a silent blank row. Same failure mode as an empty line in Load Lines From Text File - curate your input.
    • It's exactly one split pass, not per-line. Text Splitter has no concept of lines; a newline in your text is just a character that survives into the pieces. If your input is already line-based, Load Lines From Text File is the better tool - the two nodes complement each other but don't overlap.

    Installing it

    Part of qq-nodes-comfyui, no pip requirements:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kenjiqq/qq-nodes-comfyui
    

    Restart, or install qq-nodes-comfyui via ComfyUI Manager. It lives under QQNodes/Text. For a quick sanity check on what your split actually produced, connect the LIST to an Axis To STRING and a text display node once - it'll save you an hour of wondering why row two is wonky.

    CategoryQQNodes/Text

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    delimiterSTRING,

    Outputs (1)

    NameTypeDescription
    LISTLIST