Nodes/Basic data handling/splitlines (from data list)
ComfyUI Node

splitlines (from data list)

One Prompt per Line, Rendered Separately

By StableLlama·Created about a year ago·Updated about 15 hours ago· 48
splitlines (from data list)
    • STRING
    string
    keependsfalse

    You've got a text file of prompts, one per line, and you want each one rendered as its own image. That's the entire reason this node exists. splitlines (from data list) takes one string, breaks it at line boundaries, and hands ComfyUI each line as a separate item so the rest of the graph processes them individually. No Python, no API calls, no per-line manual wiring.

    How it works

    Under the hood it's literally Python's str.splitlines() - the same function you'd call in a REPL. It splits on \n, \r\n, and the rest of the Unicode line-break zoo, not just the obvious ones. The node is part of the Basic data handling pack (author StableLlama), a collection of plain Python string, list, dict, and math utilities with zero runtime dependencies. Nothing to download beyond the pack itself.

    The important part is what it returns. This variant outputs a data list - ComfyUI's native list type where each element travels down the wire as an individual item. Nodes downstream that accept a single STRING input will happily run once per line. Feed the output into a prompt encoder and you get one render per prompt automatically.

    The only input that matters is string (required, default "") - that's your multi-line blob. There's one optional toggle, keepends, default false. Flip it to true and the line breaks are kept on the end of each item instead of being stripped. You almost never need that, but it's there if you want to round-trip the text back to its original form later.

    What to do with the output

    The single output, named STRING, is a data list of strings - wire it anywhere that takes a string one-at-a-time. This is the classic setup for:

    • Batch generation - a "one prompt per line" file, each line rendered separately.
    • LoRA training prep - a list of captions, each processed individually.
    • Cleaning generated text - split a model's multi-line output so you can handle each line separately.

    There's a sibling node, splitlines (to LIST), that does the same split but packs everything into one LIST variable instead. The README for this pack spells out the decision: use a data list when you want ComfyUI to process each item individually, use a LIST when you want the whole collection handled as a unit. If you're not sure, start with this one - the per-item behavior is what most people actually want.

    Installing it

    Via ComfyUI Manager, search for "Basic data handling" and install, then restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Then restart ComfyUI. That's the whole install - no models, no weights, no requirements.txt. This is one of the rare packs where "add a node" doesn't drag in a dependency tree.

    Gotchas

    Keep an eye on the data list vs. LIST distinction. If a downstream node expects a LIST and you feed it this node's output, the wire won't connect or you'll get a type error. If that happens, you grabbed the wrong variant - use splitlines (to LIST) instead. And remember an empty line produces an empty string item, so a trailing newline in your prompt file silently gives you one blank render. Trim the file or don't sweat it; you'll spot the blank output immediately.

    CategoryBasic/STRING

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    keependsoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    STRINGSTRING