Nodes/Comfyroll Studio/βš™οΈ CR Clamp Value
ComfyUI Node Runs on cloud

βš™οΈ CR Clamp Value

Pin a number inside a min/max range

By Suzie1Β·Created 3 years agoΒ·Updated 2 years agoΒ· 1,287
βš™οΈ CR Clamp Value
    • a
    • show_help
    β—„a1.00β–Ί
    β—„range_min1.00β–Ί
    β—„range_max1.00β–Ί

    Clamping is the humble "keep this number between these two bounds" operation. If the input is below the minimum, you get the minimum; above the maximum, you get the maximum; in between, it passes through untouched. This node does exactly that, and it's the kind of thing you don't need until a value in your graph is coming from somewhere you don't fully control - a math node, a random generator, an interpolation - and you want to guarantee it stays sane.

    It's from Comfyroll Studio (Suzie1 / RockOfFire), tucked in with the pack's other numeric utilities like Math Operation and Integer Multiple. Pure logic, no generation.

    How it works

    Three numbers in, one out. It compares a against range_min and range_max and returns whichever is in-range: min(max(a, range_min), range_max), if you want it in code. Nothing clever - but exactly the guardrail you want feeding a parameter that would misbehave out of bounds.

    The inputs that matter

    • a - the value to clamp.
    • range_min - the floor. Anything below this comes out as this.
    • range_max - the ceiling. Anything above this comes out as this.

    Output is the clamped value a (a FLOAT), plus the show_help link. A common use: a schedule or gradient node is driving a denoise strength or a ControlNet weight, and you clamp it to, say, 0.0–1.0 so a runaway calculation can't push it somewhere that breaks the sampler.

    How to install it

    • ComfyUI Manager: search Comfyroll Studio, install, restart.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git, then restart.

    No models, no dependencies.

    Common issues

    Two things to keep straight. First, make sure range_min is actually less than range_max - set them backwards and the clamp bounds are nonsensical, so you'll get a constant instead of a passthrough and wonder why your value never changes.

    Second, the output is a FLOAT. If the thing downstream demands an integer (a batch size, a step count, a width), you'll need a Float To Integer conversion in between - feeding a float into an int-only input either errors or silently rounds in a way you didn't choose. Comfyroll has a conversion node for exactly that. And note the default for all three inputs is 1, so a freshly-dropped node clamps 1 to [1,1] and returns 1 until you wire real values in - that's expected, not a bug. If the node's missing from your menu, that's the Comfyroll pack failing to load, a pack-level issue rather than this node.

    Category🧩 Comfyroll Studio/πŸ› οΈ Utils/βš™οΈ Other

    Inputs (3)

    NameTypeDefaultDescription
    aFLOAT1.00-18446744073709550000–18446744073709550000β€”
    range_minFLOAT1.00-18446744073709550000–18446744073709550000β€”
    range_maxFLOAT1.00-18446744073709550000–18446744073709550000β€”

    Outputs (2)

    NameTypeDescription
    aFLOATβ€”
    show_helpSTRINGβ€”