ComfyUI Node

ITL Prompt Batch

Run N different prompts by queueing one batch — the ComfyUI for-loop

By Into-The-Latent·Created 29 days ago·Updated about 8 hours ago· 2
ITL Prompt Batch
    • positive
    • negative
    • index
    prompts_json[ { "positive": "a red fox in the snow, highly detailed, 8k", "negative": "blurry, watermark" }, { "positive": "a neon-lit city street at night, cinematic", "negative": "" } ]
    index0
    reset_index_at_batch_starttrue
    delete_empty_promptstrue
    json_in

    ComfyUI has no for-loop. It's the single most annoying thing about the engine: you can't tell it "generate these ten prompts," you queue ten runs and hope something walks the list. The classic workaround is the "Load Image Batch + increment index" trick from the batch-upscale example - but that works on a folder of images, not on text. ITL Prompt Batch is the text analog: paste a list of prompts, set ComfyUI's queue count to the number of prompts, and the node emits one positive/negative pair per run, walking the list automatically.

    If you've been copying a prompt into a KSampler, generating, pasting the next one, generating - this node ends that ritual.

    How it works

    You build a list of prompts in a row editor (each row is a positive and negative text box side by side, in the spirit of rgthree's Power Lora Loader), and the rows serialize into a hidden prompts_json field. The format is a JSON array:

    [
      { "positive": "a red fox in the snow, highly detailed, 8k", "negative": "blurry, watermark" },
      { "positive": "a neon-lit city street at night, cinematic" }
    ]
    

    positive is required and must be non-empty; negative defaults to "" when omitted. The importer also accepts convenience forms - a bare string counts as positive-only, prompt works as an alias for positive, and the array can be wrapped as { "prompts": [...] }.

    The ritual, which you'll internalize fast:

    1. Build the list.
    2. Click 🔍 Check for prompts - it validates the JSON, counts the prompts (N), and resets the index to 0.
    3. Set ComfyUI's queue/run count to N and hit run.

    The node walks 0, 1, 2… across the batch, advancing its index by 1 after each queued run - driven from JS via its own after-queued hook, so it's immune to the "Widget Value Control Mode" setting that breaks the naive increment-widget trick. If the index ever overshoots the list (more runs than prompts), it clamps to the last prompt instead of erroring.

    The inputs that matter

    • index - which prompt to emit this run (0-based). You normally don't touch it; "Check for prompts" resets it, the front-end advances it. But it's also an output, which is the useful part.
    • reset_index_at_batch_start (default on) - zeroes the index at the start of every queued batch, so each batch starts from the first prompt. Leave it on; turning it off means a batch continues from wherever the last one stopped.
    • delete_empty_prompts (default on) - drops rows with an empty positive on Check and just before a batch is queued, so blank rows never break a run or skew the count.
    • json_in (optional) - wire a text/primitive node holding a JSON prompt list here, then press 📥 Read from JSON to append it to the rows. Ignored at run time - the rows you edit are what actually runs.

    Outputs & wiring

    Outputs: positive (STRING), negative (STRING), and index (INT). Wire positive/negative into your CLIP Text Encode nodes, and wire index into a SaveImage filename suffix - that's how each saved image records which prompt made it. Without that, a batch of 10 looks like 10 copies.

    Install

    ComfyUI Manager (search "ComfyUI-IntoTheLatent-Utils") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Into-The-Latent/ComfyUI-IntoTheLatent-Utils
    

    then restart. No extra dependencies.

    One honest caveat: this node pairs especially well with the pack's own ITL Save Metadata (Civitai) node, which reads the Prompt Batch's current index at save time and records the exact line that ran - but standalone, it works with any SaveImage. Just remember the repo ships with issues disabled, so the "Check for prompts" button is your validation step; use it before queueing.

    CategoryInto The Latent/text

    Inputs (5)

    NameTypeDefaultDescription
    prompts_jsonSTRING[ { "positive": "a red fox in the snow, highly detailed, 8k", "negative": "blurry, watermark" }, { "positive": "a neon-lit city street at night, cinematic", "negative": "" } ]Authoritative prompt list as JSON. Hidden in the UI and kept in sync with the row editor by the front-end — edit the rows, not this.
    indexINT00–1000000Which prompt to emit this run (0-based). The front-end advances it by 1 after each queued run so the batch walks the list. "Check for prompts" resets it to 0.
    reset_index_at_batch_startBOOLEANtrueWhen on, the index is reset to 0 at the start of every queued batch, so each batch starts from the first prompt. Off = the index keeps its value between batches.
    delete_empty_promptsBOOLEANtrueWhen on, prompts with an empty 'positive' are dropped when you press "Check for prompts" and just before a batch is queued, so blank rows never break a run or throw off the count.
    json_inoptSTRINGOptional STRING socket. Wire a text/primitive node holding a JSON prompt list here, then press "Read from JSON" to import it into the rows. Ignored at run time — the rows you edit are what actually run.

    Outputs (3)

    NameTypeDescription
    positiveSTRING
    negativeSTRING
    indexINT