Nodes/ComfyUiNodes/M Int Clamp
ComfyUI Node

M Int Clamp

Keep a number where it belongs

By Madlumi·Created 8 months ago·Updated 8 months ago· 0
M Int Clamp
    • clamped
    x0
    lo0
    hi100

    Some values you want free; some you want on a leash. M Int Clamp is the leash: it takes an input x and pins it between lo and hi - below the floor becomes lo, above the ceiling becomes hi, anything in between passes through untouched. Output is a single INT named clamped.

    The shape is clamp(x, lo, hi) with defaults of 0, 0, and 100. Three inputs, one output, and one friendly detail: if you wire lo greater than hi, the node silently swaps them rather than producing nonsense - a small safety that keeps a bad wiring from silently wrecking a workflow.

    Where clamping earns its keep in image workflows:

    • Sanitizing computed values. A formula (say, steps derived from a size) can drift out of a sampler's valid range. Clamping guarantees the result lands where the sampler is happy instead of where the math wanted it.
    • Strength and denoise bounds. Feeding a computed strength into a LoRA or a denoise value? Clamp to the range the node accepts and you never accidentally run a negative or a >1.0 denoise.
    • Seeding a stable range. A seed that always stays within a window is easier to reason about when you're iterating.

    It composes naturally with the pack's arithmetic: add, multiply, then clamp is a complete "scale it, then keep it sane" pipeline that lives visibly in the graph.

    It ships in ComfyUiNodes (repo Madlumi/ComfyUiNodes, author "Madanie"), a small grab-bag of integer math, string helpers, and workflow-glue nodes. Install via ComfyUI Manager - search "ComfyUiNodes" - or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Madlumi/ComfyUiNodes
    

    Restart ComfyUI afterward. No pip requirements, no model downloads. It's under Add Node → mnodes → int.

    The honest take: if every value in your workflow is typed by hand, clamp is a solution in search of a problem. The moment you start computing values from other values, it becomes the difference between a graph that fails loudly and one that quietly stays in bounds.

    Categorymnodes/int

    Inputs (3)

    NameTypeDefaultDescription
    xINT0-2147483648–2147483647
    loINT0-2147483648–2147483647
    hiINT100-2147483648–2147483647

    Outputs (1)

    NameTypeDescription
    clampedINT