ComfyUI Node

in range

One node instead of a two-comparison tangle

By StableLlama·Created about a year ago·Updated 4 days ago· 48
in range
  • value
  • in_range
min_value0.00
max_value100.00
include_minTrue
include_maxTrue

Checking whether a number sits between two bounds is one of those things you do constantly in automation - "is this CFG in a sane zone?", "did the step count land in the window?", "is this value valid before I use it?" - and in most node editors it costs you two comparison nodes plus an AND. The NumberInRange node from Basic data handling collapses that whole tangle into one node with one boolean output.

It's the kind of node that looks redundant until you've built one range check by hand, and then you never go back.

How it works

The inputs, straight from the schema:

  • value - the number to test (FLOAT or INT).
  • min_value - lower bound (FLOAT, default 0).
  • max_value - upper bound (FLOAT, default 100).
  • include_min - BOOLEAN, default True: whether the lower bound is inclusive () or exclusive (>).
  • include_max - BOOLEAN, default True: whether the upper bound is inclusive () or exclusive (<).

Output is a single BOOLEAN named in_range: True when the value is inside the bounds, False otherwise.

Under the hood it's two comparisons ANDed together: value >= min_value (or > if exclusive) and value <= max_value (or <). Nothing more, which is exactly why it's nice to have in one box.

The options that matter

The two include_* toggles are the part beginners miss. With the defaults (both True), a value equal to a bound counts as in range: 50 with bounds 0..100 is True, and so is 0 or 100 exactly. Flip include_max to False and 100 becomes out of range - which is what you want for anything where the max is a "never quite reach" cap, like an index that must stay below a length.

Watch the edge case where min_value > max_value - the node won't stop you, but nothing can be in range, and you'll get False forever. If you're ever tuning a range check and it refuses to return True, check that your bounds aren't swapped.

Where you'd use it

  • Guarding a downstream step - only proceed (via a control-flow node) when a value is sane.
  • Classifying - map a continuous value into "low / mid / high" buckets with a couple of range checks.
  • Validation - a quick assert-style gate before expensive operations.

Installing it

Basic data handling is a zero-dependency pack - no models, no pip installs. ComfyUI Manager → search "Basic data handling" → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart, and in range is under Basic/comparison.

The take

This is one of the pack's genuinely useful "glue" nodes. The exclusive-bound toggles make it fit real edge cases instead of the naive version, and it replaces a three-node pile with something you can read at a glance. If you do any conditional workflow logic at all, you'll use it.

CategoryBasic/comparison

Inputs (5)

NameTypeDefaultDescription
valueFLOAT,INT
min_valueFLOAT0.00
max_valueFLOAT100.00
include_minoptBOOLEANTrue
include_maxoptBOOLEANTrue

Outputs (1)

NameTypeDescription
in_rangeBOOLEAN