ComfyUI Node

Text Split Get

Text Split Get (TextSplitGet) — ComfyUI Node

By aidec·Created 2 years ago·Updated 9 months ago· 19
Text Split Get
    • text
    • current_index
    • total
    • array
    • status
    textitem1 item2 item3 # comment
    index0
    separator_typenewline
    custom_separator|
    ignore_commenttrue
    comment_prefix#
    trim_whitespacetrue

    Text Split Get is the "give me line N from this list" node. You paste a block of text - one prompt per line, say - set an index, and it hands back that single line as a string. Nothing more glamorous than that. But it's the piece that turns a wall of text into something you can iterate over, which is exactly the thing base ComfyUI is annoyingly bad at.

    Here's the context. ComfyUI runs your graph once per queued prompt. There's no native "for each line, generate an image" - the batch button just queues the same prompt N times. So if you want twelve different prompts to run back to back, you either paste and re-queue twelve times by hand, or you keep the twelve in one text box and pull them out one at a time by index. TextSplitGet is the second half of that: the getter. Pair it with a counter or loop node feeding the index, and you've got a prompt list that walks itself.

    How it works

    It takes your text, splits it on a separator, and returns the element at index. By default it splits on newlines (one item per line), but separator_type also does comma, semicolon, or a custom string you supply in custom_separator. Two niceties on top: ignore_comment drops any line starting with comment_prefix (default #), so you can leave notes or park a prompt in the box without deleting it, and trim_whitespace cleans up stray spaces so " a photo of" and "a photo of" don't quietly become two different prompts. Both default to on, which is what you want.

    The inputs a beginner actually touches:

    • text - your list, one item per line.
    • index - which one to pull. It's 0-based, so 0 is the first line.
    • separator_type - leave it on newline unless your data is genuinely comma-separated.

    The outputs are where it earns its place. text is the selected item - wire it straight into a CLIP Text Encode as your positive prompt. total is how many items it found; feed that into your loop's count so you iterate exactly as many times as you have lines and not one more. current_index echoes the index back, array is the whole parsed list (typed *, so it'll connect to anything that accepts a list), and status is a human-readable string telling you what it did - handy when an index lands out of range and you're staring at a blank output wondering why.

    Installing it

    Painless, because there's nothing to download - no models, no chunky Python dependencies, just a few files. In ComfyUI Manager, search Comfyui_TextBatch_aidec and install. Or drop into a terminal:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aidec/Comfyui_TextBatch_aidec.git
    

    Restart ComfyUI and the TextBatch nodes show up.

    Common issues

    Most of it comes down to indices. If text comes back empty, your index is past the end of the list - check it against total (the last valid index is total - 1). If you're feeding a loop counter into index, make sure the loop stops at total, not above it. One quirk with the comment feature: comment-stripping is line-oriented, so if you switch separator_type to comma and still expect # note to vanish, don't count on it - keep comments to newline-separated lists.

    The broader thing worth knowing is what kind of node this is. It's from a small pack by a solo author (aidec, who documents the workflow over at blog.aidec.tw) - a niche utility that does one job, not a battle-tested staple like rgthree or Impact Pack. Installing any custom node runs arbitrary Python with no sandbox, so the usual caveat applies: know what you're pulling in. TextSplitGet itself is simple enough that there's little to break - the flakiness people hit in this pack lives in the queue and loop nodes that drive the index, not in the getter. If your batch is misbehaving, look upstream at what's feeding index, not here.

    CategoryTextBatch

    Inputs (7)

    NameTypeDefaultDescription
    textSTRINGitem1 item2 item3 # comment
    indexINT00–10000
    separator_typeCOMBOnewline4 options: newline, comma, semicolon, custom
    custom_separatorSTRING|
    ignore_commentBOOLEANtrue
    comment_prefixSTRING#
    trim_whitespaceBOOLEANtrue

    Outputs (5)

    NameTypeDescription
    textSTRING
    current_indexINT
    totalINT
    array*
    statusSTRING