ComfyUI Node

Read All Lines

Turn a text file into a batch of prompts

By kale4eat·Created 2 years ago·Updated 2 years ago· 0
Read All Lines
    • text
    • file_name
    file_name
    encodingutf-8

    The interesting one of the pack's two read nodes. Read All Text hands you a file as one blob; Read All Lines splits it and hands you a list - one entry per line. If you've ever kept a file of prompts, one per line, and wanted to feed that straight into a workflow as a batch, this is the node you were looking for. It's the read side of the "prompts in a text file" workflow that people keep building by hand with a pile of extra nodes.

    How it works

    Same loading story as its sibling: file_name is a dropdown populated from the text_input/ folder in your ComfyUI install root, sorted alphabetically. Pick a file, and the node runs Python's readlines(), which splits the file at newlines and returns each line as an item in a list.

    The outputs are what make it different:

    • text - a list of strings, one per line. Because it's a list, you can wire it straight into list-expecting nodes, or use it as a batch driver.
    • file_name - the filename, passed through as a plain string.

    That list output is the whole point. Pair it with something that iterates a list - a batch loop, a "for each" pattern, a prompt variation setup - and a plain .txt file becomes your workflow's data source. No yaml, no JSON, no spreadsheet: a text file of lines is the most durable, hand-editable format there is.

    The input that matters

    file_name, plus the usual optional encoding (utf-8 default). Everything hinges on the file living in ComfyUI/text_input/. Nothing in text_output/ (where the pack's write nodes save) shows up here until you move it across.

    Installing it

    ComfyUI Manager → search ComfyUI-text-file-util, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kale4eat/ComfyUI-text-file-util
    

    Restart ComfyUI. No dependencies, no pip, no models - same painless install as the rest of the pack.

    Where people get burned

    Two things, and both come straight from how readlines() behaves. First: each line keeps its line ending. Feed the output into a text prompt node and you'll get stray \n characters stuck to the end of every prompt. Plan to trim lines upstream, or pick a node that strips them. Second: a file that ends with a trailing newline gives you an empty string as the final list item, which produces a blank iteration if you're driving a batch with it. Both are easy to miss until your first run spits out a weird extra output.

    And the usual pack-level gotchas apply: the dropdown lists every file in text_input/, extension be damned, so keep that folder text-only; and if a file you just dropped in isn't in the list, restart the frontend - the options are cached at node load, not refreshed live.

    Categorytext-file-util

    Inputs (2)

    NameTypeDefaultDescription
    file_nameCOMBO0 options:
    encodingoptSTRINGutf-8

    Outputs (2)

    NameTypeDescription
    textSTRING
    file_nameSTRING