ComfyUI Node

Divide

Divide without the divide-by-zero crash

By silveroxides·Created 7 months ago·Updated 3 months ago· 3
Divide
  • operands
  • MATCHTYPE
handle_zerotrue

ComfyUI core is famously missing basic math nodes - there's a recurring community complaint about it, and honestly it's a fair one. That's exactly the hole this pack plugs, and the Divide node is one of the reasons it's worth having. It's the division you'd otherwise hand-roll with a pair of single-operation nodes or leave for the next custom pack to add. Nothing exotic: you feed it two to ten numbers, it divides them left to right, and hands you the result.

Where people actually reach for it: normalizing a value into a range, computing a percentage (part ÷ whole), scaling a resolution down, or splitting a batch size into per-replica counts. Anywhere a downstream node wants a number that's "this, divided by that," this is the cleanest way to express it.

How it works

Under the hood it's Python, done plainly. The inputs are an autogrowing list - operands - and the node walks them in order: first ÷ second ÷ third, and so on. Order matters because division isn't commutative; if you want "a divided by b" keep the divisor after the dividend.

The interesting part is handle_zero, a boolean toggle that defaults to on. When it's on and any divisor is 0, the node quietly returns 0 instead of crashing. When you turn it off, the node refuses to run and throws a "Division by zero is not allowed" validation error instead. That toggle is the whole personality of this node: leave it on and your workflow never dies on a 0 from a dangling input, but you can also bury a bug in a silent 0. If you're debugging why a downstream value looks wrong, flipping handle_zero off for a run is a fast way to find out if a 0 snuck in.

The output type follows the inputs - ints and floats both work, and you can mix them. One Python quirk worth knowing: 4 / 2 gives you 2.0, not 2, because true division always produces a float in Python. So don't be surprised when the output of two clean ints still shows a decimal.

The inputs that matter

  • operands (2–10): the numbers to divide, added with a plus button on the node.
  • handle_zero (default true): on = return 0 on divide-by-zero, off = error out.

Output is the quotient as a MATCHTYPE number, ready to wire into any int or float input.

Install

This node ships in the ComfyUI-LogicMath pack. Easiest route is ComfyUI Manager - open Manager → Custom Nodes Manager, search "ComfyUI-LogicMath", hit Install, restart. Or from a terminal:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-LogicMath

Then restart ComfyUI. There are no pip requirements and no model downloads - the pack is pure Python using only the stdlib. The one real gotcha is that it's built on ComfyUI's newer extension API, so if the nodes don't show up after install, update ComfyUI itself first.

Common issues

  • Result looks wrong after an update - check handle_zero; a silent 0 from a divisor that's actually 0 is the usual culprit.
  • Node missing from the menu - you're on an older ComfyUI that predates the extension system it needs. Update and restart.

If you only need to halve one number, sure, you could use a primitive and skip this. But the moment you're dividing a stream of computed values, this is the node that keeps the graph readable.

Categoryutils/math

Inputs (2)

NameTypeDefaultDescription
operandsCOMFY_AUTOGROW_V3
handle_zeroBOOLEANtrue

Outputs (1)

NameTypeDescription
MATCHTYPECOMFY_MATCHTYPE_V3