ComfyUI Node

Any to Integer

Convert or fail quietly, never crash

By DemonAlone·Created 7 months ago·Updated 22 days ago· 3
Any to Integer
  • input_any
  • INT

The whole-number sibling of Any to Float. Feed it anything, and if it's genuinely convertible to an integer, you get that integer back. If it isn't, the node returns None instead of throwing an error and stopping your run.

Why this exists

Once you start mixing wildcard-typed values through this pack's own adapters or another pack's "Any" nodes, you eventually need to hand one to a socket that's strict about wanting a whole number - steps on a KSampler, a batch size, a seed pulled from somewhere dynamic. A naive type cast on a bad value would crash the run right there. Any to Integer is built to convert cleanly when it can, and back off to None rather than error when it can't - which matters most if this sits inside a workflow you're not hand-monitoring on every run, where a hard crash on one bad value is worse than a value that quietly comes through as None and gets caught later.

Same caveat as its float counterpart: None here doesn't mean your workflow is safe downstream, only that this node handled the bad conversion without erroring. Whatever reads the integer next - a sampler, a loop counter, a math node - still needs an actual number, and most will error the moment they receive None in its place.

The input and output

  • input_any (optional, wildcard *) - whatever value you've got.
  • Output: a single INT, or None if conversion wasn't possible.

How to install it

ComfyUI Manager: search DemonAlone-nodes-ComfyUI, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/DemonAlone/DemonAlone-nodes-ComfyUI

then restart. No dependencies, no models - live the moment the pack loads.

Common issues & troubleshooting

I got None and something downstream still crashed. Expected, as above - this node fails soft on its own conversion, it doesn't make the rest of the graph tolerant of a missing value. Check one step upstream to see what actually arrived here.

A decimal value came in and I expected rounding, not a straight fail. Whether a float like 7.5 converts cleanly or not depends on how the underlying conversion is implemented - don't assume it truncates or rounds by convention. If you need explicit rounding behavior, do that conversion deliberately (a math node) before this one, rather than relying on this converter's default handling.

Which converter - this, or Any to Float? Depends entirely on what the target socket wants. Whole-number inputs (steps, batch size, seed) want this one; anything expecting a decimal (cfg, denoise) wants Any to Float instead. Feeding an integer output into a float-only socket usually still works fine in ComfyUI; the reverse - a float where a strict integer is required - is more likely to cause trouble.

Do I need this if my source already outputs INT? No, wire straight through - this only matters for a wildcard-typed source landing on a strict INT input.

Categoryutils

Inputs (1)

NameTypeDefaultDescription
input_anyopt*

Outputs (1)

NameTypeDescription
INTINT