Comfy Prompt Iterator — ComfyUI Custom Node
A ComfyUI node that automatically steps through prompts in a text file on each generation run, so you can test multiple prompt variations without touching the graph between runs.
https://www.theoath.studio/projects/comfy-prompt-iterator
Install
cp ComfyUI/custom_nodes/
git clone [email protected]:OATH-Studio/comfy-prompt-iterator.git
# restart ComfyUIThe node appears in the node browser under utils/prompt → Prompt Iterator.
Inputs
InputTypeDescriptionprompt_fileDropdownThe text file containing prompts (one per line) from prompt_texts foldercontrol_after_generateDropdownHow to advance the prompt selection after each run
Outputs
OutputTypeDescriptionprompt_textSTRINGThe current prompt text (useful for connecting to PromptString nodes)current_indexINTOne-based index of the current prompt in the filetotal_promptsINTTotal prompts in the selected file
control_after_generate
This is the key feature. After each generation completes, the node advances its internal prompt selection according to the chosen mode:
ModeBehaviourfixedAlways uses the same prompt — nothing changes between runsincrementMoves forward one prompt each run. Wraps back to 0 after the last onedecrementMoves backward one prompt each run. Wraps to the last one after index 0randomizePicks a random prompt from the list each run
Example: You have 10 prompts in your variations.txt file. Set control_after_generate to increment. Queue 10 runs — each generation automatically uses the next prompt with zero manual intervention.
File organisation
Create a prompt_texts folder inside this custom node directory:
ComfyUI/custom_nodes/comfy-prompt-iterator/prompt_texts/
base_prompts.txt
a beautiful portrait of a woman, detailed face, cinematic lighting
a beautiful landscape, sunset, mountains in background
variations.txt
add blur effect to the image
add grainy film texture
add vibrant colors and high contrastAdding your own prompt files
Create a new
.txtfile insideprompt_texts/(e.g.,my_prompts.txt)Add one prompt per line:
first prompt variation here second prompt variation here third prompt variation hereEmpty lines are automatically ignored
Restart ComfyUI or refresh the node list to see new files in the dropdown
Each .txt file should contain one prompt per line. The node will read all .txt files from prompt_texts/ and display them in a dropdown.
Typical workflow
Prompt Iterator → Prompt (or CLIPTextEncode) → KSampler → SaveImage
↑
set control_after_generate = increment
queue N runs (one per prompt variation)Connect the prompt_text output to a Prompt node or directly to a CLIPTextEncode node's text input. This lets you automatically test multiple prompts without manually changing them between generations.
Using with filename prefix
Combine with a Filename Prefix node to organize outputs:
Filename Prefix (text from prompt_text output) → Save ImageThis embeds the current prompt variation in your saved filenames for easy tracking of which prompt produced which result.
