Nodes/ComfyUI-PromptLoop/πŸ”„ Prompt Loop (File)
ComfyUI Node

πŸ”„ Prompt Loop (File)

Your prompt .txt file, rendered as a whole batch on one queue job

By max-dingsdaΒ·Created 10 months agoΒ·Updated 6 months agoΒ· 0
πŸ”„ Prompt Loop (File)
    • prompt
    β—„fileprompts.txtβ–Ί
    β—„start_index0β–Ί
    β—„max_prompts0β–Ί

    You have forty prompts you want rendered, and you do not want to queue them one at a time, wait, save, then type the next one. That's the exact question people keep asking the ComfyUI community - "pull prompts from a file and run them one after another, how do you do your nightly gens?" - and PromptLoopFromFile is the minimal answer. One .txt file with one prompt per line, one click on Queue, and ComfyUI renders every line as its own image. No scripting, no API, no external service.

    It's part of a small pack (max-dingsda/ComfyUI-PromptLoop) whose whole job is turning a text list into a batch. This node is the file-based version; a sibling node does the same with a plain multiline box.

    How it works

    The trick is barely a trick at all - it's a stock ComfyUI engine behavior that this node exploits. The node reads your file, strips blank lines, and returns the lines as a list. Because that output is declared as a list, ComfyUI doesn't just hand the list downstream - it expands: it runs everything downstream of the node once per list item. So your CLIPTextEncode β†’ KSampler β†’ VAEDecode chain executes once per prompt, all from a single queue entry.

    That's the whole mechanism, and it's why the pack's tagline - "One queue job β†’ many images" - is genuinely true. The looping isn't reimplemented in Python; the engine does it. The file is read once per queue job, and each expansion pass gets one clean prompt string.

    The inputs that matter

    Only three, and you'll set two of them:

    • file (required) - a dropdown of every .txt file sitting in ComfyUI/input/. Defaults to prompts.txt.
    • start_index - skip the first N prompts. Default 0. Handy when you re-render a batch and don't want to redo the ones you already liked.
    • max_prompts - 0 means "all of them"; otherwise it caps how many lines get used. This is your safety valve.

    The single output is prompt (a list of strings). Wire it into a CLIP Text Encode positive input - or the negative if you want every image to share the same negative. During expansion each image gets its own line.

    Installation

    This is the rare custom node that installs clean because it has nothing to install. requirements.txt is empty - no torch pins, no model downloads, nothing. Node classes are written in the classic 2023-era style and register under the promptloop category.

    Easiest path: ComfyUI Manager β†’ search "ComfyUI-PromptLoop" β†’ install. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/max-dingsda/ComfyUI-PromptLoop
    

    Then restart ComfyUI. No extra Python packages, no model files to fetch.

    Where people get burned

    • FileNotFoundError - the dropdown default is prompts.txt, but the file has to actually exist in ComfyUI/input/ (that's the input folder, not custom_nodes). Drop it in the right place first.
    • The dropdown is stale. The file list is read when the node loads. Add a new .txt after the node is already on the canvas and it won't appear until you reload the workflow or restart ComfyUI.
    • "No prompts found" error - start_index is past the end of your list, or every line was blank. It also throws if the file exists but is empty.
    • Save as UTF-8. The reader opens files with explicit UTF-8 encoding, so a file saved in Windows' default codepage with special characters can blow up. Save your .txt as UTF-8 and it won't.
    • Every queue click is a full batch. Three lines in the file means three images, every single time you hit Queue. That's the feature - until it isn't. Set max_prompts or trim the file when you only want one.

    One honest framing note: this is the no-frills member of the "prompt list β†’ batch" family. Wildcard-heavy users reach for Dynamic Prompts; people who want CSV parameter grids use a scheduler. If your need is literally "one prompt per line, render them all," this is the least-moving-parts version - and with zero dependencies, it's the easiest to trust on an overnight run.

    Categorypromptloop

    Inputs (3)

    NameTypeDefaultDescription
    fileCOMBOprompts.txt0 options:
    start_indexoptINT00–10000β€”
    max_promptsoptINT00–10000β€”

    Outputs (1)

    NameTypeDescription
    promptSTRINGβ€”