ComfyUI Node

range

Generate number sequences on the fly

By StableLlama·Created about a year ago·Updated 4 days ago· 48
range
    • LIST
    start0
    stop10
    step1

    The node that makes a LIST out of thin air

    Plenty of list nodes in this pack take a list and rearrange it. This one creates one: give it a start, a stop, and a step, and it hands you a LIST of numbers - Python's range() with a ComfyUI face. If you've ever wanted "a list of seeds from 100 to 110" or "every other number from 0 to 20" without typing them by hand, this is the generator.

    It's the kind of node that feels pointless until you need it, then you wonder how you did without it. Combined with the pack's "convert to Data List" node, you can turn a range into a fan-out: generate 10 numbers, convert, and let a node after process each one individually.

    How it works

    Under the hood it's just list(range(start, stop, step)). The one rule to remember from Python that surprises people: stop is exclusive. start=0, stop=10 gives you 0 through 9, not 10. Step can be negative too - start=10, stop=0, step=-2 gives you [10, 8, 6, 4, 2] - though for a beginner the default forward direction covers 99% of use cases.

    The step-0 case is guarded: the node raises a clear "Step cannot be zero" error rather than silently doing something weird. That's the one failure mode you can actually hit, and the error message tells you exactly what's wrong.

    Inputs and outputs

    • start (INT, default 0) - first number in the list.
    • stop (INT, default 10) - where to end before; not included.
    • step (INT, default 1) - how much to jump each time.

    Output is a single LIST - a Python list of ints, the pack's LIST type. Wire it into the other LIST nodes (sort, reverse, shuffle, slice) or convert it to a data list to fan items out individually.

    Installing it

    Ships in Basic data handling by StableLlama, the r/StableDiffusion poster better known for his long model writeups than for code. This pack is featherweight: zero runtime dependencies, no model files, nothing that touches your GPU.

    Install via ComfyUI Manager (search "Basic data handling") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart ComfyUI and look under Basic/LIST.

    Troubleshooting

    The classic mistake is assuming stop is inclusive, so you get one fewer number than you expected. Count the list; if it's short by one, bump stop up. The other gotcha: step=0 errors on purpose, and very large ranges (millions of steps) are legal but will make your graph crawl - this is a real list in memory, not a lazy iterator. Keep ranges modest and you'll be fine.

    CategoryBasic/LIST

    Inputs (3)

    NameTypeDefaultDescription
    startINT0
    stopINT10
    stepoptINT1

    Outputs (1)

    NameTypeDescription
    LISTLIST