ComfyUI-AICoser-SplitLines
One block of text, one prompt per line — batch prompts from a single paste
- texts
Here's a workflow that's older than ComfyUI: you keep your prompts in a notes file, one per line, and you'd love to just paste the whole block in and generate all of them. AICoser_SplitLines is the node that makes that paste work. It takes one multiline string, splits it into a list of lines, and hands you a STRING list ready for a batch loop.
The use case is batch generation from a text file. Paste a hundred prompt lines, split them, feed the list into this pack's queue or batch nodes (or any list-iterating node), and let the machine grind through all of them. It's the text side of the same "load a pile of things and process them all" pattern the pack's BatchLoadImages handles for images.
How it works
It's a string splitter with opinions, and the opinions are the useful part. Before splitting, it normalizes all the ways a "newline" can hide:
- Real line breaks -
\r\n, bare\r, and the unicode separators - all become\n. - HTML
<br>and<br/>tags become newlines ifsplit_html_bris on (handy if you're pasting from a rich text source). - Literal escaped
\n(backslash-n, as you'd see in JSON or some API output) becomes a real newline - but only if the text doesn't already contain real newlines. That guard keeps you from double-splitting text that mixes both.
Then it splits, and two toggles clean up the result: trim strips whitespace off each line, and ignore_empty drops blank lines so you don't get phantom empty prompts from trailing newlines.
The inputs that matter
- text - the multiline string to split (wire in from a TextBox or paste source).
- ignore_empty (default on) - drop blank lines.
- trim (default on) - strip whitespace from each line.
- split_escaped_newline (default on) - honor literal
\nas a break when there are no real newlines. - split_html_br (default on) - treat
<br>as a line break.
Output: texts (STRING, as a list) - one item per line, in order. Note the edge case: if you feed it a string that's already a list, it passes the list through untouched, so it composes with other list nodes.
Installing it
Part of ComfyUI-AICoser-Tools, same one-time install:
cd ComfyUI/custom_nodes
git clone https://github.com/aicoser-sister/ComfyUI-AICoser-Tools
Restart ComfyUI, or install via ComfyUI Manager by searching "ComfyUI-AICoser-Tools". No dependencies beyond ComfyUI.
Common issues
- "My literal \n lines didn't split" - the escaped-newline conversion only runs when the text has no real newlines. If your text mixes real breaks with literal
\nsequences, the literal ones stay literal. That's a deliberate guard, not a bug. - Output looks shorter than my text -
ignore_emptyandtrimare on by default, so blank lines and stray spaces vanish. Turnignore_emptyoff if you genuinely need to preserve the blank positions. - A list won't plug into a single-string node - same story as TextList: the output is a list type. It feeds batch/loop nodes, or you index into it, not straight into a CLIP Text Encode.
It's a five-toggle utility, but it's the difference between pasting a hundred prompts manually and pasting them once. For anyone who keeps prompt libraries as text files, this is the node that pays for the pack's install all by itself.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| textopt | STRING | — | |
| ignore_emptyopt | BOOLEAN | true | — |
| trimopt | BOOLEAN | true | — |
| split_escaped_newlineopt | BOOLEAN | true | — |
| split_html_bropt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| texts | STRING | — |