Nodes/ComfyUI-List-Utils/Create Linspace
ComfyUI Node

Create Linspace

An exact number of evenly spaced values, endpoints included

By godmt·Created 2 years ago·Updated about a month ago· 16
Create Linspace
    • FLOAT
    • PYLIST
    • length
    start0.00
    stop1.00
    num10

    If Create Arange is "give me values every step apart, however many that turns out to be," Create Linspace is the opposite mindset: "give me exactly num values, evenly spaced, from start to stop, and include both ends." It's numpy.linspace(start, stop, num), and it's the node you reach for when you want a precise, known count - five CFG values from 5 to 15, say, no floating-point surprises about whether you got four or five.

    How it works

    Set start, stop, and num. The node generates num values, evenly spaced, running from start to stop inclusive - unlike Create Arange, where the stop boundary is typically excluded, linspace guarantees the last value in the output equals stop exactly. That's the whole reason this node exists alongside Create Arange: when you care about hitting a specific endpoint precisely and knowing your count up front, linspace is the correct tool, and arange's step-based, float-precision-dependent count becomes a liability instead of a convenience.

    A concrete example: Create Linspace(5, 15, 5) gives you [5, 7.5, 10, 12.5, 15] - five values, evenly spaced, both 5 and 15 present. Wire the FLOAT List into a sampler parameter and you get a clean five-run sweep with the endpoints guaranteed.

    The inputs and outputs that matter

    • start - first value in the output.
    • stop - last value in the output. Unlike Create Arange, numpy.linspace does include this value.
    • num (default 10, minimum 2) - how many values to generate. The minimum of 2 makes sense once you think about it: with fewer than two points you can't have both a start and an end, so the node won't let you go lower.

    Three outputs: FLOAT as a ComfyUI List for per-item execution, PYLIST as one array value, and length - though with this node length will always just equal whatever you set num to, so it's more of a confirmation than a discovery.

    How to install it

    Search "ComfyUI-List-Utils" in ComfyUI Manager, or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/godmt/ComfyUI-List-Utils.git
    

    Restart ComfyUI. numpy ships with ComfyUI already, so there's no extra dependency to chase down for this node.

    Common issues & troubleshooting

    Expected the spacing between values but got a different number than you calculated. Remember num is the total count of values, not the number of gaps between them - five values means four gaps, not five. If you're used to thinking in step size, work backwards: (stop - start) / (num - 1) is the actual spacing you'll get.

    Values don't line up with a "nice" step like 0.5 or 1.0. That's expected when stop - start doesn't divide evenly by num - 1. If you specifically need round-number steps, Create Arange with an explicit step will give you that at the cost of not knowing your exact count in advance - pick whichever constraint (exact count vs. exact step) matters more for your test.

    Only wanted a step-based sweep and don't care about hitting the exact endpoint. Create Arange is the better fit there - it's driven by step size rather than count, and doesn't force you to reason about num - 1 gaps.

    Categorylist_utils

    Inputs (3)

    NameTypeDefaultDescription
    startFLOAT0.00First value.
    stopFLOAT1.00Last value. numpy.linspace() includes this value.
    numINT10Number of values to generate.

    Outputs (3)

    NameTypeDescription
    FLOATFLOATGenerated values as a ComfyUI List-processing output.
    PYLISTPYLISTGenerated values as one Python list value.
    lengthINTNumber of generated items.