Nodes/ComfyUI Logic Support/Number Range Index
ComfyUI Node

Number Range Index

Which bucket did your number land in?

By narusas·Created about a year ago·Updated about a year ago· 0
Number Range Index
    • I
    number5
    base_typeL <= n < R
    value_11
    value_210
    value_320
    value_430
    value_540
    value_650
    value_760
    value_870
    value_980
    value_1090
    value_11100
    value_12110
    value_13120
    value_14130
    value_15140
    default_index0

    Say a value - a person's age, an image's dimensions, a score - needs to be categorized before your workflow knows what to do with it. That's the flagship use of Number Range Index, and the whole reason the pack's author built the README example around it. You give it a number and up to 15 boundary values; it figures out which slice of the number line the input falls into; and it outputs the index of that slice. That index is then the key to everything downstream.

    Here's the mechanism. The node takes your value_1 through value_15 boundaries, dedupes them, and sorts them ascending. Your number then gets placed against those boundaries and the node returns which range it belongs to, offset by default_index (default 0). A base_type dropdown picks the boundary convention: L <= n < R treats the lower edge as included and the upper as excluded, L < n <= R flips it. The defaults are already a working staircase - value_1 is 1, then 10, 20, 30… up to 140 - so with zero configuration you've got bins of ten. Drop in the number 5 and you get 0 (it's in the first bin).

    The inputs that matter:

    • number - the value to bucket. INT, like the rest of this pack.
    • value_1value_15 - the boundaries. This is where the fiddling lives.
    • default_index - what you get when the number falls outside every range, and the base you add range indices onto.

    Out comes one INT: default_index plus the range's position. Wire it straight into a String Switch By Number node and you've recreated the README's canonical trick - age 37 gets bucketed, the bucket number picks "middle-aged" from the switch, and a String Concatenator assembles the final prompt. That's a genuinely useful pattern for dynamic prompt building without hard-coding branches.

    Two gotchas before you trust it. First, the default boundaries are all active - leave value_4 at 30 and it still defines a bin, even if you only set two boundaries yourself. Overwrite everything you don't want. Second, the boundary math is easy to misjudge around the edges: with L <= n < R, a number exactly equal to a boundary lands in the lower bin, and a number past the last boundary still returns the last range's index rather than an error. Test your edge values once and you'll never think about it again.

    Install is the pack-standard one-liner:

    cd ComfyUI/custom_nodes
    git clone https://github.com/narusas/Comfyui-Logic-Support
    

    Restart ComfyUI or refresh the page afterward - or use ComfyUI Manager and search for "ComfyUI Logic Support." The whole pack is pure Python with no dependencies and no models to download, so there's no install risk and no dependency hell to inherit. It's MIT-licensed, single-author (narusas), and quiet in the community; you install it for what the nodes do, not for its reputation.

    CategoryLogic-Support

    Inputs (18)

    NameTypeDefaultDescription
    numberINT5
    base_typeCOMBOL <= n < R2 options: L <= n < R, L < n <= R
    value_1INT1
    value_2INT10
    value_3INT20
    value_4INT30
    value_5INT40
    value_6INT50
    value_7INT60
    value_8INT70
    value_9INT80
    value_10INT90
    value_11INT100
    value_12INT110
    value_13INT120
    value_14INT130
    value_15INT140
    default_indexINT0

    Outputs (1)

    NameTypeDescription
    IINT