ComfyUI Node

range

Generate a sequence of numbers, Python-style

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

    If you've ever wanted to generate "all the numbers from 0 to 9" or "every 5th frame" without typing them out, DataListRange is your node. It's Python's range() function exposed in the node graph, and it produces a data list of INT values you can feed into anything that wants a list of numbers.

    Three inputs, and only the first two are required:

    • start - where the sequence begins (default 0)
    • stop - where it ends, exclusive (default 10)
    • step - how much to jump each time (default 1)

    The output is a single list of integers. With defaults, that's 0, 1, 2, …, 9. Set start=0, stop=100, step=10 and you get 0, 10, 20, …, 90.

    How it works

    It's literally list(range(start, stop, step)). Two Python semantics you need to internalize or you'll be surprised:

    1. stop is exclusive. range(0, 10) gives you 0 through 9, not 10. This trips up everyone once.
    2. Negative steps work. start=10, stop=0, step=-1 counts down. Setting step to 0 raises a ValueError, which is the one hard failure this node has - the workflow will complain loudly, so don't do it.

    Because the output is a data list, each number flows out as an individual item. That makes it the natural driver for anything that wants to iterate over a fixed count: batch of frame numbers, a series of strength values you later map to floats, an index sequence for a get item or set item chain.

    Where it fits

    The most common real-world use is scheduling - generate a list of steps or CFG values, pair it with a DataListZip to combine with a matching list of prompts, and you've got the skeleton of a prompt-travel or parameter-sweep workflow. It's also the quickest way to test whether a downstream node handles a list correctly: generate 0..4, wire it in, and check the count with DataListLength.

    Installing it

    Part of StableLlama's Basic data handling pack - pure Python, no dependencies, no models to download. Install once, get every node:

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

    Restart ComfyUI, or install via ComfyUI Manager by searching "Basic data handling". There's no requirements.txt to fight with, because the pack only uses the standard library.

    Common issues

    Beyond the exclusive-stop trap and the step-zero error, the one gotcha is expecting the output to include stop. It won't - that's Python behavior, not a bug. If you need the last number included, just set stop one higher than what you actually want. And as with the rest of the pack, the output is a data list of ints; if a downstream node wants floats, run it through the pack's cast nodes.

    CategoryBasic/Data List

    Inputs (3)

    NameTypeDefaultDescription
    startINT0
    stopINT10
    stepoptINT1

    Outputs (1)

    NameTypeDescription
    INTINT