Nodes/ComfyUI-ZhiHui/🎨 智绘_文本按分隔符拆分
ComfyUI Node

🎨 智绘_文本按分隔符拆分

Turn one text into many — the node that makes ComfyUI run your prompt list

By zhuyungen·Created 8 months ago·Updated 3 months ago· 0
🎨 智绘_文本按分隔符拆分
    • string_list
    text
    delimiter,
    start_index0
    skip_count0
    max_count1

    ComfyUI has a batch system most people discover by accident: when a node outputs a list instead of a single value, the downstream graph re-runs once per item. ZH_TextSplitByDelimiter ("🎨 智绘_文本按分隔符拆分") is a lever for exactly that. Paste cat, dog, bird, fish into one box, set the delimiter to a comma, and instead of one generation you get four - one per animal - because the output is a string list that fans out into the rest of the workflow.

    It's from ComfyUI-ZhiHui, a Chinese-language utility pack. It's a small node doing one mechanical thing, but that one thing unlocks the whole "batch of prompts" workflow that people otherwise hack together with loops and repeated graph copies.

    How it works

    Split the text on delimiter, strip whitespace, drop empty fragments. Then three knobs shape the selection:

    • start_index - skip the first N fragments.
    • skip_count - step through the list, picking every (skip_count + 1)th fragment. 0 means consecutive (1, 2, 3…), 1 means every other (1, 3, 5…).
    • max_count - cap how many fragments come out.

    The output is declared with OUTPUT_IS_LIST = True, which is the whole trick: ComfyUI sees a list, treats it as a batch, and runs every downstream node once per fragment - so a CLIP Text Encode downstream of this generates one prompt per split piece, and a SaveImage downstream writes one file per piece. Set max_count to 5 and the graph processes exactly the first five fragments, even if the source text had 50.

    The inputs and outputs that matter

    • text - the multiline string to split.
    • delimiter - the separator. Default ,. Use \n (the two-character escape, not a literal newline) to split on line breaks.
    • start_index, skip_count, max_count - the slicing controls above.

    Single output: string_list (STRING, delivered as a list). If the input ends up empty, it returns one empty string rather than nothing - the graph stays alive.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git
    

    Restart ComfyUI. Base deps only, no models. ComfyUI Manager search "ComfyUI-ZhiHui" also works.

    Where people get burned

    The list-output surprise is the recurring theme in this pack, and it's acute here: connect this to anything not built for lists and it'll silently multiply your runs. If you only want one generation, keep max_count at its default of 1 - the default is deliberately conservative. Second, the \n delimiter is a string-literal gotcha: typing an actual line break into the delimiter field won't work; you need the two characters backslash-n, and the source special-cases exactly that. And a data note: empty fragments are dropped before slicing, so a comma list with stray double commas won't produce blank prompts - good, but it also means your start_index counts only non-empty items, which can shift numbering if your source text is messy.

    Category智绘灵箱/文本

    Inputs (5)

    NameTypeDefaultDescription
    textSTRING
    delimiterSTRING,
    start_indexINT0
    skip_countINT0
    max_countINT11–1000

    Outputs (1)

    NameTypeDescription
    string_listSTRING