Snap to Divisible
Round a number to a multiple your model actually needs
- value
Most diffusion and video models don't take arbitrary width and height - the VAE downsamples by a fixed factor, commonly 8, and some architectures want dimensions divisible by even larger numbers (16, 32, 64) so everything tiles cleanly through every stage of the network. Pull a width off a resize node, or type in a number you saw in a spec sheet, and there's a real chance it isn't a clean multiple of whatever your pipeline actually needs. Snap to Divisible exists to fix that in one node instead of doing the division and rounding in your head every time.
What it's for
Anywhere a computed or hand-entered dimension needs to land on a specific multiple before it reaches a sampler, an EmptyLatentImage, or a video model's frame-size input. In this pack it pairs naturally with Resize Image and Mask by Side - resize to roughly the size you want first, then snap the result to whatever divisibility your downstream model requires, rather than baking a guess into the resize step itself.
The inputs and outputs that matter
Just two fields, both plain integers:
value(default 1024, range 0–65536) - the number you want snapped.divisible_by(default 16, range 1–65536) - the multiple to round to.
Output: value - the corrected number, ready to plug straight into whatever needs a clean multiple.
There's no rounding-mode selector here - unlike this pack's WAN Frame Calculator, which explicitly offers nearest/max/min, this node doesn't expose that choice. Treat its behavior as rounding to the nearest valid multiple, and if you specifically need to always round up (never go under a minimum) or always round down (never exceed a hard cap), check the actual output against what you expected and adjust your input value with a small buffer if it lands on the wrong side for your case.
How to install it
Search "Link Comfy Nodes" in ComfyUI Manager and install from there. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt
Restart ComfyUI. This is pure integer math - no extra dependencies or downloads.
Common issues & troubleshooting
Nothing changes and you expected it to. If value is already an exact multiple of divisible_by, the output passes through unchanged - that's correct behavior, not a sign something's broken. Double-check divisible_by is actually set to what you think it is if you expected a different result.
divisible_by set to 1. Every integer is divisible by 1, so this setting is a no-op by definition - if you're not seeing any snapping happen at all, verify you haven't left this at its lowest value by mistake.
Not knowing which direction it rounded. With no rounding-mode option and no tooltip documenting the exact behavior, always check the actual value output rather than assuming a direction - especially if you're chasing a hard minimum or maximum rather than just "close enough."
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | INT | 10240–65536 | — |
| divisible_by | INT | 161–65536 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | INT | — |