Nodes/ComfyUI-iTools/Prompt Loader
ComfyUI Node

Prompt Loader

Pull one line out of a prompts.txt file by index

By MohammadAboulEla·Created 2 years ago·Updated 6 days ago· 236
Prompt Loader
    • prompt
    • count
    file_pathprompts.txt
    seed0

    If you keep a running text file of prompts - one per line, built up over months of generating - this node is how you pull one back out. Give it a file path and an index, and it returns the prompt sitting on that line. It's the read half of a pair; the write half is this pack's Prompt Saver, which appends a prompt to the same kind of file. Together they let you build a personal prompt library without a database, a spreadsheet, or leaving ComfyUI.

    How it works

    Point file_path at a .txt file where each line is one prompt. The node reads that line and returns it as a string, counting from zero - line 0 is the first line, not the first line after some header. There's a naming quirk worth knowing up front: the index field is literally called seed, not index or line, even though what it actually selects is a specific line number, not a random draw. Don't be thrown by the name - treat it exactly like a line index.

    The inputs and outputs that matter

    • file_path - full path to a .txt file, one prompt per line. Defaults to prompts.txt, which the README frames as pointing at a sample file bundled in the pack's examples folder; for your own library, give it a full, real path.
    • seed - the line index, 0 to 65535. Despite the name, this is not noise - it's which line gets returned.

    Outputs: prompt (the STRING you'll wire to a CLIP Text Encode or Prompt Styler) and count - the number of lines available in the file, useful as a batch limit if you're looping through the whole list rather than pulling one fixed line.

    Installing it

    Via ComfyUI Manager: search "iTools" or "ComfyUI-iTools," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MohammadAboulEla/ComfyUI-iTools
    

    then restart. No special dependencies - it's reading a plain text file.

    Troubleshooting

    Node errors or comes back empty. Check the path first - prompts.txt on its own is a relative path, and depending on where ComfyUI was launched from, "relative" might not point where you think. The README's own advice is to give it a full path rather than relying on the relative default once you're using your own file.

    Wrong prompt comes back. Remember indexing starts at 0, and the field controlling it is named seed rather than something more obvious like index - it's easy to assume line 1 is index 1 when it's actually index 0, or to skim past the field entirely because "seed" reads as a noise control at first glance.

    File has blank lines or stray whitespace mixed in. The node reads lines as-is; if you built the file by hand or pasted from somewhere with inconsistent line endings, an "empty" prompt at a given index is usually a genuinely blank line in the source file, not a bug in the loader.

    You want to cycle through the whole file automatically rather than fetch one fixed line. Wire count into whatever's driving your batch loop, and increment the seed widget per iteration up to count - 1 - that turns a static file lookup into a full run through your saved prompt library.

    CategoryiTools

    Inputs (2)

    NameTypeDefaultDescription
    file_pathSTRINGprompts.txt
    seedINT00–65535

    Outputs (2)

    NameTypeDescription
    promptSTRING
    countINT