XRange Node
The counter that ticks one step on every run
- current_value
- range_list
- overflow
ComfyUI's graph is a DAG - no built-in loops, no for loop, no cycles allowed. So when people build batch, seeding, or frame-stepping workflows, iteration is done with nodes that carry state between runs. XRange is one of those: a Python-style range() that advances its cursor by one on every graph execution and hands you the current value, the full list, and an overflow flag. It's the counter node you didn't know you needed until you try to rotate seeds or walk through a list of presets.
It ships in comfy-ovum, sfinktah's utility pack, under the "Folder, Range, and Sequence Utilities" section. Pure logic, no models, no VRAM - it's one of those deceptively simple nodes that unlocks a whole category of workflow.
How it works
Every execution, the node checks its internal cursor, outputs the value at that position, then bumps the cursor for next time. The arithmetic is exactly Python's range(start, stop, step): current value = start + cursor * step. It marks itself as always-changed, so it re-runs and ticks forward even when nothing upstream changed - that's the whole trick.
The inputs, in order of how often you'll touch them:
stop(INT string) - end, exclusive. The only required field; blank it and the node errors at runtime.start(default 0) andstep(default 1) - leave blank for defaults.stepcan be negative, exactly like Python, but never zero.repeat(BOOLEAN) - when the cursor runs past the end, wrap back to the start instead of stopping.advance(BOOLEAN, default true) - disable to freeze the cursor in place.reset(BOOLEAN) - restart from the beginning on this run.cursor(INT) - the raw index. You can read or set it directly to jump around.
Three outputs: current_value (INT), range_list (LIST - the full expanded range), and overflow (BOOLEAN).
The trick that makes it useful
The overflow flag is the interesting bit. It goes true when the range is exhausted or when it wraps on repeat. The node's own documentation shows the classic composition: to build a minutes→hours clock, make one XRange 0..60 with repeat=true and another 0..24 with repeat=true, then wire minutes.overflow → hours.advance. The hours counter ticks once each time minutes wraps. That's how you compose counting systems out of these without illegal graph cycles - and the same pattern covers multi-digit counters, seed ladders, and rate-limited triggers.
When to reach for it
Seed rotation per run, stepping through a list of checkpoints or presets, indexing into a batch, frame counters for video work. If your workflow has ever had the thought "I want this to be a different value every time I run it," XRange is a solid first answer.
Installing it
ComfyUI Manager → search comfy-ovum → install → restart. Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
The pack's requirements.txt is modest (requests, aiohttp, pillow, numpy, plus small extras) - no checkpoints, nothing heavy.
Gotchas
step = 0 is a hard error, and so is a blank stop. If the range comes out empty (e.g. start ≥ stop with a positive step), current_value returns 0 and overflow is already true - that's the node telling you your arithmetic is backwards, not a bug. And since start/stop/step are string widgets, keep them numeric; whitespace is treated as "use the default."
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| startopt | STRING | 0 | Optional start as integer string. Blank/whitespace -> 0. |
| stopopt | STRING | 10 | Required stop as integer string. Leave blank to error at runtime. |
| stepopt | STRING | 1 | Optional step as integer string. Blank/whitespace -> 1. Non-zero. Can be negative. |
| repeatopt | BOOLEAN | false | When enabled, wraps to beginning after reaching the end (or to end for negative step). |
| cursoropt | INT | 0 | Current index into the range as integer string. |
| advanceopt | BOOLEAN | true | Disable to pause at the current value. |
| resetopt | BOOLEAN | false | When True, restart at the beginning. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| current_value | INT | — |
| range_list | LIST | — |
| overflow | BOOLEAN | — |