modulus
The remainder node — what's left after you divide
- INT
Modulus is the workhorse of "every Nth thing" logic, and modulus from the Basic data handling pack is that operator in node form: divide one integer by another and keep only the remainder. 10 % 3 is 1. 100 % 10 is 0. If you've ever wanted "do something every 5th frame" or "toggle when the count is even," this is the node that gets you there.
What it does
It computes int1 % int2 - Python's remainder operator. That's the whole job, with two details worth knowing:
- It returns
0exactly whenint1divides evenly byint2. That makes== 0the classic "every Nth" test:frame % 5 == 0fires on frames 0, 5, 10… - The sign follows Python's rule: the result takes the sign of the divisor.
-10 % 3is2, not-1. If you're porting expectations from C or JavaScript, this will surprise you exactly once, so it's worth deciding consciously whether that matters in your logic.
Like the pack's divide node, it draws the line at zero: int2 == 0 raises a ValueError. There's no "safe" remainder variant, so if your divisor can be zero, guard it upstream.
Inputs and outputs
int1- INT, default0. The value being divided.int2- INT, default1. The divisor.- Output
INT- the remainder.
Install
From the Basic data handling pack. ComfyUI Manager → search "Basic data handling" → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
then restart ComfyUI. No dependencies, no model downloads.
How it fits a workflow
The pair to know is divide + modulus side by side: one gives the quotient, the other the remainder, and together they let you decompose any value into "how many whole groups" and "what's left over." The classic ComfyUI pattern is modulus feeding a comparison node (result == 0) to build a frame-based or batch-based condition - every N iterations, do the heavy pass. Keep the divisor positive unless you enjoy debugging sign weirdness.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| int1 | INT | 0 | — |
| int2 | INT | 1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |