Nodes/ComfyUI_Lam/文本分割转列表
ComfyUI Node

文本分割转列表

One big text block in, an array out

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
文本分割转列表
    • 下标i文本
    • 数组
    • 数组长度
    text
    i0
    delimiter

    LongTextToList ("文本分割转列表", split text into a list) does one boring, essential thing: it splits a big blob of text on a delimiter and gives you a list, plus a single element at an index you choose, plus the list length. If you've ever pasted fifty prompts into one multiline box and wished ComfyUI would just iterate them, this is the node that starts the machinery.

    ComfyUI has no native text-splitting. Core's text nodes treat a string as a string. But the whole point of a node graph is that you can batch things - and to batch text, you need it to become a list. This node is the hand-off. It's the poor-man's batch iterator: split your prompts, hand the list to something like the pack's MultiTextEncode, and generate once per line.

    How it works

    It's literally text.split(delimiter) under the hood, plus a convenience index. Three behaviors matter:

    • The delimiter is whatever string you type, but \n gets translated to an actual newline. So type \n to split on line breaks - which is what most people want when they paste a column of prompts.
    • The i input indexes into the resulting array and returns that one element directly. You can drive i from a seed, a counter, or a loop node to walk the list.
    • You get the length out too, which is what you use to know how many iterations your loop needs.

    The split is naive - no trimming, no skipping empty lines. A trailing newline leaves an empty string at the end of your array, and an i past the end throws an index error that kills the queue.

    The inputs and outputs

    • text - the multiline block to split.
    • i - the index of the element you want on the 下标i文本 output (0–99999).
    • delimiter - the split string; use \n for newline separation.
    • Outputs: 下标i文本 (the element at index i), 数组 (the full list), 数组长度 (the list's length).

    Installing it

    This is one of the text utilities in ComfyUI_Lam. Install the pack via ComfyUI Manager (search "ComfyUI_Lam") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yanlang0123/ComfyUI_Lam
    

    Restart, and it's in the lam category. It needs no models and no extra pip packages beyond what ships with the pack, so it's one of the safer nodes here to use without touching the pack's heavy install steps.

    Common issues

    Two traps, both about the delimiter. First, if you split on a comma or a space and your prompts contain commas, you'll get unexpected fragments - pick a delimiter your content doesn't contain, or use \n with one prompt per line. Second, remember the \n translation goes one way: it converts the two characters backslash-n into a real newline, so if your text genuinely contains the literal text \n (not a newline), it'll be split there too.

    Everything else is the pack's standard baggage rather than this node's fault. ComfyUI_Lam's README will try to talk you into a full environment setup with pinned old packages from the Aliyun mirror - skip it for a text node like this. And if you uninstall the pack later and see a leftover Chinese popup at startup ("请先添加AppParams节点"), remove ComfyUI/web/extensions/lam; the pack's frontend extension doesn't clean up after itself.

    Categorylam

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    iINT00–99999
    delimiterSTRING

    Outputs (3)

    NameTypeDescription
    下标i文本STRING
    数组LIST
    数组长度INT