Nodes/ComfyUI-XJNodes/Text List From File
ComfyUI Node

Text List From File

Turn a text file into a list of prompts

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Text List From File
    • text_list
    file_path

    If you've ever batch-generated prompt variations by copy-pasting a different prompt into the same workflow over and over, you already know the pain. XJTextListFromFile is the boring little node that ends it: it reads a .txt or .md file from your ComfyUI input folder and hands you every entry in it as a list of strings. Wire that list into your loop or your list-expanding pipeline and one queue run becomes a hundred.

    It comes from ComfyUI-XJNodes (github.com/alexjx/ComfyUI-XJNodes), a small modular pack of list, text, image and loop helpers. The README is upfront that it's "primarily for personal use and experimentation" - it's a hobbyist's toolkit, not a marquee pack, and there's no big community around it. What it lacks in fame it makes up for in not being a 30-node grab bag you install for one feature. This node does one thing, and the author wrote it to actually use it.

    How it works

    Under the hood it's dead simple. When you open the node, ComfyUI scans ComfyUI/input/ for every file ending in .txt or .md and offers them in a file_path dropdown. Pick one and the node reads it, parses it, and returns a text_list output (a proper list of strings - the node declares OUTPUT_IS_LIST, so ComfyUI treats it as a real list, not a single string).

    The parsing is where it's slightly clever. The format is YAML-ish:

    • Lines starting with - start a new item (the dash is stripped).
    • Lines starting with # are comments and get skipped.
    • Any other line continues the current item, so multi-line prompts work - continuation lines keep their indentation.

    A file like this:

    # the good stuff
    - cinematic portrait of a fox, soft rim light
      shallow depth of field, 85mm
    - a fox in a snowstorm, motion blur
    

    gives you two list entries, the first being the two-line prompt as one string. If the file doesn't exist or is missing, you get an empty list rather than a crash - which is friendlier than most nodes in this genre.

    The one input you set

    • file_path - the dropdown of .txt/.md files in your input folder. That's it. No weights, no toggles, no hidden mode.

    The text_list output feeds naturally into loop nodes, into a batch of CLIPTextEncode calls, or anywhere else that consumes lists of strings. It pairs well with the pack's own loop system (XJLoopStart/XJLoopEnd) if you want to iterate prompts one at a time, or with any list-driven batch workflow.

    Installing it

    Via ComfyUI Manager, search "XJNodes" (or "ComfyUI-XJNodes") and hit Install, or clone it by hand:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/alexjx/ComfyUI-XJNodes.git
    

    Then restart ComfyUI. Good news on dependencies: the pack's requirements.txt is empty - this node only uses folder_paths, which ships with ComfyUI itself. No torch version fights, no model downloads, no CUDA requirements.

    Where people get burned

    The classic gotcha: you drop your file somewhere sensible like your desktop or ComfyUI/models/, and it never shows up in the dropdown. The node only looks in one place - ComfyUI/input/ - and only at .txt/.md files sitting directly in it (no subfolders). Drop the file there and refresh the node. A couple of other notes worth knowing: the dropdown is populated at node-load time, so new files may need a refresh to appear, and because the file is read fresh on every execution, editing the file between queue runs picks up changes without restarting. That edit-and-rerun loop is honestly the nicest part of the whole node.

    CategoryXJNodes/text

    Inputs (1)

    NameTypeDefaultDescription
    file_pathCOMBO1 options:

    Outputs (1)

    NameTypeDescription
    text_listSTRING