Number Range Index
Which bucket did your number land in?
- I
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_1…value_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.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| number | INT | 5 | — |
| base_type | COMBO | L <= n < R | 2 options: L <= n < R, L < n <= R |
| value_1 | INT | 1 | — |
| value_2 | INT | 10 | — |
| value_3 | INT | 20 | — |
| value_4 | INT | 30 | — |
| value_5 | INT | 40 | — |
| value_6 | INT | 50 | — |
| value_7 | INT | 60 | — |
| value_8 | INT | 70 | — |
| value_9 | INT | 80 | — |
| value_10 | INT | 90 | — |
| value_11 | INT | 100 | — |
| value_12 | INT | 110 | — |
| value_13 | INT | 120 | — |
| value_14 | INT | 130 | — |
| value_15 | INT | 140 | — |
| default_index | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| I | INT | — |