Nodes/ComfyUI-Practical-Tools/Text Line To List
ComfyUI Node

Text Line To List

Split your prompt list into real list output

By wenchengxiang·Created about a month ago·Updated a day ago· 1
Text Line To List
    • list
    text

    Text Line To List does one thing: takes a multiline text box, splits it on newlines, throws away the empty lines, and outputs a list of strings through a single list-typed socket. You type a prompt per line and a batch workflow consumes them one by one.

    If you've done any list-driven ComfyUI work you already know the gap it fills. Loaders and iterators that process several items - a list of prompts, a list of LoRA names, a list of file paths - want a STRING list on a list socket, not a single blob of text. But text comes into your graph as one string, and most text nodes hand back one string. This node is the bridge: the box is a comfortable place to keep your batch of values visible and editable, and the output is genuinely list-typed (OUTPUT_IS_LIST), so it plugs straight into list-aware consumers.

    That makes it the natural partner for the batch-prompt pattern: keep ten prompt variants in one multiline box, feed this node, and let a per-item iterator generate an image per line. Same idea for a list of checkpoint names driving a test grid, or a list of negative prompts you want to sweep through. It's the text-version of "one source, many consumers" - except here the source is a collection, and the consumers are the list nodes.

    How it works

    Splitting is simple and deliberate: split on \n, then drop lines that are empty or whitespace-only (line.strip() is empty). So blank lines, stray spaces-only lines, and trailing newlines all vanish - you can leave tidy gaps in your box without producing empty entries. Leading/trailing whitespace on a kept line stays, which is usually harmless for prompts but worth remembering if you're feeding filenames (a trailing space will break a path).

    One input, one output:

    • text - the multiline STRING. You can type directly into it, and since it's a normal widget (not force-input), you can also wire it from a prompt book or another text source if you prefer.
    • list (output) - the STRING list, one item per non-empty line, in the order you typed them.

    How to install it

    Part of ComfyUI-Practical-Tools by wenchengxiang. ComfyUI Manager → search ComfyUI-Practical-Tools → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
    

    Standard library only; nothing to download.

    Common issues

    • "I'm connected but only the first line runs." Check the consumer. This node outputs a list; if the downstream node takes a single string and silently ignores the list, only the first item is read. The list output is for list-aware nodes - check that your consumer's socket is list-typed.
    • Trailing spaces in filenames. Lines aren't trimmed, so a stray space after a path becomes part of the path and the file won't load. Trim before relying on it for file names.
    • Carriage returns. If your text came from a Windows-copied source, \r\n line endings can leave stray \r characters on kept lines. Pasting fresh text into ComfyUI's box usually avoids this, but it's worth knowing if paths mysteriously fail.
    CategoryPractical-Tools/String

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    listSTRING