ComfyUI Node

MapRange_AS

Remap any number from one range to another — with a bonus INT

By flyingshutter·Created 3 years ago·Updated about a year ago· 8
MapRange_AS
    • FLOAT
    • INT
    value0.00
    in_00.00
    in_11.00
    out_00.00
    out_11.00

    MapRange_AS is a linear range remapper, the classic "map this value from one range into another" utility you know from every animation and audio tool. Feed it a number in the input range, and it gives you the equivalent number in the output range. You set five values, you get two outputs (a float and a rounded int), and the whole thing is a single formula.

    It's part of flyingshutter's As_ComfyUI_CustomNodes, a dependency-free playground pack - no models, no installs beyond the clone, and no frills.

    How it works

    The math is the standard linear interpolation:

    t = (value - in_0) / (in_1 - in_0)
    result = out_0 + t * (out_1 - out_0)
    

    So value is normalized to a 0–1 position within the input range, then that position is applied to the output range. A value exactly halfway between in_0 and in_1 lands exactly halfway between out_0 and out_1. Values outside the input range still map (it extrapolates linearly, it doesn't clamp), which is useful - just know it's not clipping.

    The inputs that matter

    • value - the number you're remapping.
    • in_0, in_1 - the low and high ends of the input range.
    • out_0, out_1 - the low and high ends of the output range.

    The outputs are FLOAT (the exact remapped value) and INT (that same value rounded). Having both is genuinely handy - you can wire the float into a parameter that wants precision and the int into one that needs a whole number, all from a single node.

    Where you'd use it

    Range remapping is everywhere once you look for it. Turning a seed or a slider that runs 0–100 into a steps value that runs 10–40. Converting a denoise strength (0–1) into a weight (0–2) for a LoRA or ControlNet. Mapping a frame index into a color or position parameter for animation. Anytime you have a value in one unit system and need it in another, this is the two-second fix - and it beats doing the math in your head, or stacking four Math nodes to get the same formula.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/flyingshutter/As_ComfyUI_CustomNodes
    

    Restart ComfyUI and it's under ASNodes (or ComfyUI Manager → "As_ComfyUI_CustomNodes").

    Common issues

    • in_0 equal to in_1. If both ends of the input range are the same, the formula divides by zero. The node raises a clear ValueError ("in_0 and in_1 are equal") rather than silently producing garbage, so at least you'll know - just make sure your input range is actually a range.
    • Expecting clamping. It doesn't clamp. Feed a value beyond your input range and you get an extrapolated output, which can surprise you if you assumed a hard limit. Add your own clamp node if you need one.
    • Backwards ranges. Inverted ranges (in_0 > in_1) work mathematically - the mapping just goes the other way. Fine if intended, confusing if not.

    It's a small, predictable utility that does exactly one formula well. If you've ever wished ComfyUI had a "remap this number" node, this is it.

    CategoryASNodes

    Inputs (5)

    NameTypeDefaultDescription
    valueFLOAT0.00
    in_0FLOAT0.00
    in_1FLOAT1.00
    out_0FLOAT0.00
    out_1FLOAT1.00

    Outputs (2)

    NameTypeDescription
    FLOATFLOAT
    INTINT