Skip to main content
Batch generation means running one workflow many times and changing something between the runs: the seed, the prompt, the CFG, the sampler, the model, or several of these at once. A settings grid is one use of it: the same prompt and seed, with one or two settings changed per cell, so you can see what each setting does. This guide starts with the simplest case and adds one step at a time:
  1. Batch seeds: many variations of one prompt
  2. Batch prompts: one run per prompt
  3. Batch any setting: one run per value of CFG, steps or any other input
  4. Loops: Start Loop and End Loop
  5. Settings grids: crossing two or more settings and laying out the results
  6. Scripting with the Comfy API: any combination, at any size
A CFG sweep at one seed: CFG 3, 6 and 9 with SDXL, labelled and arranged by the Make Image Grid node
Some steps use custom nodes. Every custom node named on this page is installed on Comfy Cloud, where custom nodes are reviewed before they are added. On your own ComfyUI, install the node pack first.

Batch Seeds

The seed decides the starting noise, so a new seed gives a new composition of the same prompt. Changing the seed is the simplest batch.

Batch Count

Batch count sits in the run bar next to the Run button. It sets how many times the workflow is queued per click. See the run bar for where it is.
  1. Set control after generate on the KSampler seed to randomize or increment.
  2. Set Batch count to the number of images you want.
  3. Click Run. Each queued run gets the next seed.
control after generate works on any number widget that has it, not only the seed. If every widget is set to fixed, every queued run is identical and gives the same image.

batch_size on the Latent

batch_size on the Empty Latent Image node creates several latents at once, and the KSampler denoises them together in one pass. Each image in the batch gets different noise.
  1. On Empty Latent Image, set batch_size to the number of images, for example 4.
  2. Click Run. Save Image saves all of them.
A larger batch uses more VRAM, since all images are sampled at the same time.

Specific Seeds

To re-run seeds you already like, for example to compare them under a new setting, feed the seed from a list:
  1. Add an Int node for each seed.
  2. Add a Create List node and connect each Int to its next free input. New inputs appear as you connect.
  3. Connect the list output of Create List to the seed input of the KSampler.
  4. Click Run. The KSampler runs once per seed.
The next section explains how lists work.

Batch Prompts

When a node receives a list, ComfyUI runs it once for each item and passes every result downstream. A list of prompts connected to CLIP Text Encode gives one image per prompt.

One Text Node per Prompt

  1. Add a Text (Multiline) node for each prompt.
  2. Join them with Create List.
  3. Connect the list output to the text input of the positive CLIP Text Encode.
  4. Click Run. Each prompt is encoded and sampled as its own run.

One Prompt per Line

For more than a few prompts, keep them in one text box, one prompt per line, and split it into a list with the splitlines (from data list) node from the Basic data handling pack.
  1. Add a Text (Multiline) node and write one prompt per line.
  2. Add a splitlines (from data list) node (search for splitlines) and connect the text to its string input. Leave keepends off, so the line breaks are not part of the prompts.
  3. Connect its output to the text input of the positive CLIP Text Encode.
  4. Click Run. Each line becomes its own run.
You can paste a whole prompt file into the text box this way. Empty lines become empty prompts, so remove them first.

Batch Any Setting

A list can feed almost any input, not only the seed and the prompt. To connect a list to a widget such as cfg, drag the link onto the widget. To sweep CFG:
  1. Add a Float node for each CFG value, for example 3, 6 and 9.
  2. Join them with Create List and connect the list to the cfg input of the KSampler.
  3. Keep the seed fixed: set control after generate on the seed to fixed.
  4. Connect VAE Decode to a Make Image Grid node and then to Save Image.
  5. Click Run. The KSampler and VAE Decode run once per CFG value, and Make Image Grid receives all the images.
steps, denoise, image size and LoRA strength work the same way, with Int or Float nodes.
When a node gets more than one list, ComfyUI pairs the items by position: the first with the first, the second with the second, and the last item of the shorter list repeats. It does not make every combination. Three prompts and three seeds give three images, not nine. To cross two settings, see Settings grids or Scripting.
Dropdowns. sampler_name, scheduler and model files are dropdowns, which a list of text values cannot feed directly. To compare a few, copy the KSampler and VAE Decode nodes once per value, connect them to the same model, prompts and latent, set each copy differently, and collect the images with Make Image Grid. For samplers and schedulers, the XY plot node in Settings grids is quicker.

Loops

The Start Loop and End Loop nodes run the nodes between them once per iteration. Start Loop has three modes: To loop over a list of values, for example CFG:
  1. Build the list with Float nodes and Create List, as above. A list of prompts or seeds works the same way.
  2. Add a Start Loop node, set mode to List, and connect the list to its list input.
  3. Connect list_item from Start Loop to the input you want to change, here the cfg input of the KSampler.
  4. Add an End Loop node. Connect the IMAGE output of VAE Decode to output_value, and turn on accumulate so End Loop returns the image from every iteration, not only the last one.
  5. Connect the outputs of End Loop to Make Image Grid, then to Save Image.
  6. Click Run.
For one list, a loop and a plain list give the same images. A loop also lets one iteration pass a value to the next (next_iteration_value on End Loop, current_iteration_value on Start Loop), and a loop can be nested inside another by connecting the outer loop’s iteration_index to the inner loop’s parent_iteration.
Start Loop and End Loop are recent core nodes. If you can’t find them, update ComfyUI. Comfy Cloud updates after each ComfyUI stable release.

Settings Grids

A settings grid holds the prompt, the model and the seed constant, and changes only sampler settings, so any difference between two cells comes from the setting you changed. With a random seed, each cell would also get a different composition, and you could no longer tell whether a change came from the setting or from the noise. The four KSampler settings that change an image the most, apart from the prompt and the model, are: A full sweep multiplies quickly: 4 CFG values × 3 step counts × 3 samplers × 2 schedulers is 72 images. Start with one or two settings, find the range that looks good, then narrow it.
Open-model workflow pages on the Comfy Hub have a Grid tab with a pre-rendered CFG × steps × sampler × scheduler sweep at one seed. You can browse it to find good settings for that model, then re-run the cells you choose on Comfy Cloud with your own prompt.

Crossing Settings with an XY Plot Node

The FL KSampler XYZ Plot node from the Fill-Nodes pack replaces the KSampler and crosses up to three settings for you. It renders every combination and returns one image with the values written along the axes.
  1. Replace the KSampler with FL KSampler XYZ Plot. Connect model, positive, negative, latent_image, and the vae from your checkpoint loader.
  2. Set the seed and the base values for the settings you are not changing.
  3. Set x_axis and y_axis to two of steps, cfg, denoise, sampler_name and scheduler.
  4. Type the values for each axis into x_values and y_values, separated by commas, for example euler,dpmpp_2m and 4,8.
  5. To cross a third setting, set z_axis and z_values. z_stack_mode places the extra grids below or beside each other.
  6. Connect the IMAGE output to Save Image and click Run.
An XY plot from FL KSampler XYZ Plot: euler and dpmpp_2m across, CFG 4 and 8 down, one seed To cross other inputs, such as prompts × seeds or LoRA strength × CFG, use nested loops or a script.

Laying Out Your Own Grid

When the images come from a list or a loop, the Make Image Grid node arranges them in rows, left to right and top to bottom. To label each cell, put a Draw Text Overlay node between VAE Decode and Make Image Grid. Build a second list of labels, such as CFG 3, CFG 6 and CFG 9, with Text nodes and Create List, and connect it to the text input. Because the images and the labels are both lists, each image gets the label at the same position. The grid at the top of this page was made this way.

Scripting with the Comfy API

Past two or three settings, or to cross prompts, seeds and models, a script is simpler than a graph. It builds every combination, submits each one as its own job, and saves the results with a record of what each run changed.

1. Export the Workflow in API Format

  1. Build and test the workflow for one run in ComfyUI.
  2. Open the workflow menu and choose Export (API). This saves the graph in API format, where every node is keyed by its ID.
  3. Open the JSON and note the ID of each node you want to change. In the default text-to-image workflow, the KSampler is "3" and the positive CLIP Text Encode is "6".

2. Queue One Job per Combination

Comfy API v2 accepts the API-format graph at POST /api/v2/jobs and returns a job you can poll at GET /api/v2/jobs/{id}. The same API runs on Comfy Cloud and, through comfy-api-proxy, on your own ComfyUI, so the script below works on both by changing BASE_URL. Comfy Cloud runs a set number of jobs at a time per plan and holds the rest in a queue: You can have up to 100 jobs queued. Running more than one job at a time needs the API and a paid plan. See Cloud concurrency limits for details. In AXES, each key is <node ID>.<input name> and each value is the list of values to try. The script runs every combination. It keeps at most MAX_IN_FLIGHT jobs submitted at a time, so a large batch never fills the queue, and it backs off when the server answers 429. It needs Python 3.9 or newer and pip install requests. Set COMFY_API_KEY to your API key first.
batch.py
The files are numbered (0000_0.png, 0001_0.png and so on), and batch/manifest.json records the settings of each one. Some common AXES entries:
The Comfy SDKs for Python and TypeScript wrap these endpoints, including uploads, waiting for jobs and retrying when the queue is full.

3. Lay Out the Results

To turn a scripted batch into a grid, assemble the saved files with a few lines of Pillow (pip install pillow). This example puts one setting on the columns and another on the rows, holds the rest fixed, and writes the values along the edges:
make_grid.py
Make one sheet per combination of the remaining settings, for example one CFG × sampler sheet for each prompt.

Try It Yourself

  1. Download the grid image at the top of this page and drag it into ComfyUI. It loads the CFG sweep workflow (it uses sd_xl_base_1.0.safetensors).
  2. Replace the Float nodes with Int nodes and connect the list to seed instead, or replace them with a splitlines (from data list) node and connect it to the prompt.
  3. When you need every combination of several settings, export the workflow with Export (API) and run it with the script.