Nodes/ComfyUI-Buff-Nodes/Multiline Text Splitter (Buff)
ComfyUI Node

Multiline Text Splitter (Buff)

One big text block in, up to twenty smaller blocks out

By BuffMcBigHuge·Created 2 years ago·Updated 20 days ago· 2
Multiline Text Splitter (Buff)
    • text_1
    • text_2
    • text_3
    • text_4
    • text_5
    • text_6
    • text_7
    • text_8
    • text_9
    • text_10
    • text_11
    • text_12
    • text_13
    • text_14
    • text_15
    • text_16
    • text_17
    • text_18
    • text_19
    • text_20
    input_text
    num_outputs2
    lines_per_output1
    split_evenlyFalse
    remove_empty_linesFalse

    Multiline text is the awkward middle child of ComfyUI. A file of captions or a list of prompt variants is great as a blob, but useless until each line is its own string you can route somewhere. MultilineTextSplitter takes a big text block and fans it out across 1–20 output sockets - one line per output, or a fixed chunk per output, whichever you need.

    The workflow this enables is the batch-prompt pattern: you keep a list of prompts or subjects in a text widget (or feed it from a file), split it into individual strings, and wire each output to its own path in the graph - separate samplers, separate conditioning, separate anything. It's the "make several things from one text" valve.

    How it works

    It splits the input on newlines, then distributes lines to outputs in one of two ways. With split_evenly on, lines are handed out round-robin / evenly across the num_outputs fields you asked for. With it off, each output gets a fixed lines_per_output chunk in sequence - output 1 gets lines 1..N, output 2 gets the next N, and so on. Lines that don't fit in the requested number of outputs are simply dropped. remove_empty_lines strips blank lines before splitting if you want clean output.

    The mechanism detail worth knowing: all 20 outputs (text_1 through text_20) exist on the backend no matter what. Set num_outputs to 3 and the other 17 return empty strings - which is exactly why this node is API-safe: a raw Prompt API workflow can connect text_7 even if the browser node only shows three sockets. Unused outputs returning "" also means downstream string consumers get a defined value instead of a missing-key error, which is friendlier than it looks.

    The inputs

    • input_text - the multiline block.
    • num_outputs - 1–20, how many fields you want.
    • lines_per_output - chunk size when not splitting evenly.
    • split_evenly - evenly distribute, or chunk sequentially.
    • remove_empty_lines - strip blanks first.

    There's no single "output" - you read whichever text_N sockets you wired up, and ignore the rest.

    Install

    From BuffMcBigHuge's pack - ComfyUI Manager (search "ComfyUI-Buff-Nodes") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/BuffMcBigHuge/ComfyUI-Buff-Nodes
    

    Restart ComfyUI. Zero extra dependencies.

    Gotchas

    The traps are the ones you'd expect from a splitter. If you set num_outputs higher than the line count, the extras come back empty - fine for pipes, confusing if you expected padding. If you set it lower than the line count, lines silently fall off the end. And "split evenly" with 5 lines across 2 outputs isn't symmetric magic; check the tooltips, because the exact distribution behavior lives in the author's implementation and the README's description is the source of truth. It's a dead-simple node with a specific job: un-flatten multiline text. For prompt batching and caption fan-out, it's exactly the right tool.

    Categoryutils

    Inputs (5)

    NameTypeDefaultDescription
    input_textSTRINGMultiline text input to split into multiple outputs
    num_outputsINT21–20Number of output text fields to create
    lines_per_outputINT11–1000Number of lines per output (used when split_evenly is False)
    split_evenlyCOMBOFalseWhen True, splits lines evenly across outputs. When False, uses lines_per_output for each output sequentially.
    remove_empty_linesoptCOMBOFalseWhen True, removes empty lines from the input before processing. When False, empty lines are preserved.

    Outputs (20)

    NameTypeDescription
    text_1STRING
    text_2STRING
    text_3STRING
    text_4STRING
    text_5STRING
    text_6STRING
    text_7STRING
    text_8STRING
    text_9STRING
    text_10STRING
    text_11STRING
    text_12STRING
    text_13STRING
    text_14STRING
    text_15STRING
    text_16STRING
    text_17STRING
    text_18STRING
    text_19STRING
    text_20STRING