ComfyUI Node

max

Max — the biggest value in the list, with a merciful failure mode

By StableLlama·Created about a year ago·Updated 4 days ago· 48
max
  • list
  • max_value

max finds the largest value in a LIST. It's the node you reach for when a workflow needs "the peak" - the highest seed, the largest dimension, the top score - without you manually comparing a pile of numbers. The pack also ships min for the opposite, and if you've got a list of comparable numbers, these two are the quickest wins in the LIST category.

How it works

It's Python's max() wrapped in a guard:

if not list:
    return (None,)
try:
    return (max(list),)
except (TypeError, ValueError):
    return (None,)

Two failure modes are handled instead of thrown. An empty list returns None, and a list whose items aren't comparable also returns None - for example, a mix of strings and numbers, where Python can't decide ordering. That's merciful: the node won't crash your graph. But it means None flows downstream, so a "max" that silently comes back None is usually telling you your list is empty or mixed-type.

For lists of numbers it's straightforward and deterministic - largest value wins, ties resolve to that value regardless of position. For lists of strings it uses lexicographic order, which is usually what you want for version-like names, but remember "10" < "9" when strings are compared as strings.

The output is a single max_value of whatever type the winning element is (*).

Where you'd use it

  • Peak tracking. Highest score, largest frame count, biggest dimension in a batch.
  • Bounding. Compare max against a threshold with <= to decide if anything in the batch exceeds a limit.
  • Sanity checks. After building a list, confirm max looks sane before you trust the rest of the pipeline.

Installing

Part of the "Basic data handling" pack by StableLlama. ComfyUI Manager: search "Basic data handling", install, restart. Or:

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

Restart ComfyUI. Zero dependencies, no models - pure Python, one of the simplest installs there is.

Gotchas worth knowing

  • None comes back for empty or non-comparable lists - check your list's contents before trusting the result.
  • String "max" is lexicographic, not numeric - "10" sorts before "9". For numeric sorting, ensure the list holds numbers.
  • It operates on the pack's LIST type, not a native data list - the same distinction that runs through the whole pack.
CategoryBasic/LIST

Inputs (1)

NameTypeDefaultDescription
listLIST

Outputs (1)

NameTypeDescription
max_value*