🪠️ WWAA Nested Loop Counter
Nested for-loops, in a node you can actually wire up
- i
- j
- i_float
- j_float
- debug_log
If you've ever wanted to iterate over two things at once in ComfyUI - every LoRA with every strength, every seed range with every prompt - you've discovered ComfyUI doesn't ship a loop node. The WWAA Nested Loop Counter is the team at WeirdWonderfulAI.Art's answer: a stateful i/j counter that behaves exactly like a pair of nested for loops, and it remembers where it is between runs.
When the author posted it on r/comfyui the replies were polite but honest: "when you need nested loops you might want to move from ComfyUI to actual programming." Fair - but this isn't a workflow executor, it's a counter that drives other nodes. You feed its outputs into index-based things (image grid cells, LoRA stacks, string lists) and each run of the graph advances the state by one step. That's the pattern: it's a state machine you pull on, not a loop you hand a body to. If you genuinely need lazy execution and real looping, the community will point you at execution-inversion or ControlFlowUtils instead. For "generate 4×4 variations by advancing two counters," this is the simpler tool.
How it works
The node keeps current_i and current_j in memory. Each run, it returns the current pair, then advances j by increment. When j reaches max_value, it resets to 0 and bumps i by increment. When i hits max_value, both reset to 0 and the cycle starts over. So with max_value 10 and increment 1 you get 100 (i, j) pairs before it wraps.
Because it's stateful, it reports itself as always-changed - ComfyUI runs it every pass even if nothing upstream changed. That's the intended behavior; flip reset to True once to zero both counters and start the cycle fresh.
Inputs and outputs
max_value(1–10000) - cap for both counters.increment(1–1000) - step size. Useful for e.g. stepping LoRA strength by 0.1 if you wire the float output through math.reset- force both back to 0.
Outputs: i and j as INTs, i_float and j_float as FLOATs (handy when you need a fractional value for a weight), and debug_log, a string that narrates the state transition each run - genuinely useful the first time you wire it up to confirm it's stepping the way you think.
Installing it
It's part of WWAA-CustomNodes, so install the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/hgabha/WWAA-CustomNodes
Restart ComfyUI. Or use ComfyUI Manager and search "WWAA Custom Nodes". You'll find it under 🪠️ WWAA/utilities. No models, no extra dependencies beyond the pack's stated none.
Gotchas
The statefulness cuts both ways. If you're mid-cycle and you edit the workflow, the counter keeps counting - you don't automatically start at (0,0). That's why reset exists; some people put it on a frontend-toggled input so they can restart the run from the queue. And keep in mind it's a counter, not a scheduler: it won't pause for a sampler to finish or respect batch sizes. For pure "advance two counters and let the graph re-run" workflows, it does exactly what it says on the tin.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| max_value | INT | 101–10000 | — |
| increment | INT | 11–1000 | — |
| reset | BOOLEAN | false | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| i | INT | — |
| j | INT | — |
| i_float | FLOAT | — |
| j_float | FLOAT | — |
| debug_log | STRING | — |