Prompt Looper
Alternate up to four scenes in a loop without a spaghetti graph
- image1
- image2
- image3
- image4
- index
- prompt
- image
Looping workflows are where ComfyUI graphs go to die - four prompts, four images, a batch counter, and a wall of switches that nobody can trace. Prompt Looper is the pack's answer: give it up to four prompt/image pairs and an index, and it hands back the one pair that index points at, wrapping around when you run out. One node, three wires out, and your "alternate between these scenes" logic stops being a wiring exercise.
How it works
index is an INT (from a loop/counter node, or manual). prompt1/image1 are required; prompt2 through prompt4 (and their images) are optional. On execution it collects the pairs you filled, counts them, and does index % count - so index 0 returns scene 1, index 1 returns scene 2, and when the index climbs past the number of scenes it wraps back to the start. It also breaks at the first empty prompt, so you don't have to worry about a stray blank slot in the middle of your list.
The pairing logic is worth calling out: the loop picks prompts and images together - you can't get scene 1's image with scene 2's prompt, which is exactly the consistency guarantee a scene-swap loop needs. Each iteration of your loop gets a coherent (prompt, image) pair, wired straight into your sampler and your conditioning.
The inputs that matter
index- the driver. Wire it to whatever increments per iteration.prompt1/image1- required, and scene 1 is the fallback everything wraps to.- The optional pairs 2–4 - your additional scenes, only as many as you need.
Output
Three sockets: index (the wrapped index, echoed back so downstream can log or use it), prompt (the selected prompt string), and image (the selected image tensor). Wire prompt into your text encoder and image into your I2V first-frame input.
Where it fits
It's the direct sibling of TKPromptLooperAdv - this one is for when you want to type your pairs straight into the node, and the Advanced version is for when the pairs come from a TKMultiImagePrompt list. For a quick "three takes of the same scene with different text" loop, this is the one you'd actually reach for; if your scenes live in the input folder and you want twelve of them, use the Advanced pair instead.
Common issues
The index comes in unwrapped from your loop, so if your loop counter starts at 1 (not 0) your first iteration will show scene 2 - start counters at 0 or subtract 1. And the node only wraps within what you filled: fill three pairs and index 3 returns scene 1, which surprises people who assumed "past the end" means "stop." That's the design - looping is the point. If a pair is missing its prompt, that pair is silently dropped from the count.
Installing it
Part of trashkollector/TKNodes ("ComfyUI Handy Nodes"). Install via ComfyUI Manager (search "Handy Nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/trashkollector/TKNodes
Restart, and it's under TKNodes. No dependencies.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 00–100 | — |
| prompt1 | STRING | prompt 1 | |
| image1 | IMAGE | — | |
| prompt2opt | STRING | prompt 2 | |
| image2opt | IMAGE | — | |
| prompt3opt | STRING | prompt 3 | |
| image3opt | IMAGE | — | |
| prompt4opt | STRING | prompt 4 | |
| image4opt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| index | INT | — |
| prompt | STRING | — |
| image | IMAGE | — |