Nodes/ComfyUI Prepack/đź’€Prepack Number Type Converter
ComfyUI Node

đź’€Prepack Number Type Converter

Feed it any number, get string, int, and float out — the one converter you'll stop noticing

By S4MUEL-404·Created 12 months ago·Updated 10 months ago· 2
đź’€Prepack Number Type Converter
  • value
  • string
  • int
  • float

ComfyUI's type system is strict, and the number types are the worst offenders: an INT wire won't plug into a FLOAT socket, a STRING holding "3.5" is not a number at all, and every node you download seems to want a different one. The đź’€Prepack Number Type Converter is the small utility that makes the mismatch disappear - it accepts string, int, or float on the single input, and hands you all three types back on separate outputs. You wire it once and never think about the type boundary again.

This is the kind of node that looks trivial until you've spent an afternoon chasing "expected FLOAT, got INT" errors on a workflow you didn't write. Then it looks like a gift.

How it works

The input value is typed as * - a wildcard - so it accepts any of the three numeric shapes. The conversion logic is straightforward:

  • string - str(value) with surrounding whitespace stripped.
  • float - float(value), so a string like "3.5" becomes the float 3.5, and an int 4 becomes 4.0.
  • int - float(value) then rounded, so "3.5" gives 4 and 4.9 gives 5.

The three outputs are named string, int, float, and you just pull the one you need. If you need two representations for different downstream nodes - a filename string and a numeric value, say - the single node covers both.

The rounding on the int output is worth internalizing: this node rounds, it does not truncate. 3.7 becomes 4, not 3. If a workflow's math depends on truncation you'll want a different node, but for the usual "I just need an int that's close enough" case, rounding is what you want.

Where people get burned

The error path is the gotcha. If the input can't be converted - a string like "hello", or a value with unexpected formatting - the node catches the failure and returns safe defaults: the string as-is, int 0, float 0.0. That means bad input produces a quiet 0 instead of a loud error, which can make a downstream failure mystifying ("why is my CFG 0?"). Check the console for the [Prepack] ❌ line if numbers look wrong.

Also keep in mind it's a number converter, not a general text tool. It'll happily turn "42" into an int, but it's not a string-slicer or a formatter - float("0x2A") style exotic formats will fail to the zero fallback.

Installing it

It comes with the Prepack pack:

cd ComfyUI/custom_nodes
git clone https://github.com/S4MUEL-404/ComfyUI-Prepack.git
pip install -r ComfyUI-Prepack/requirements.txt

Or search "Prepack" in ComfyUI Manager. Dependencies are just PyTorch, NumPy, and Pillow - you already have them. Restart, find it under đź’€Prepack. No models to download, nothing to configure.

If the node refuses a wire, check the source of that wire - the wildcard input accepts number types, but it won't accept, say, a CONDITIONING or IMAGE (those aren't numbers and shouldn't be). And if your int comes out one higher than you expected, remember: rounding, not truncation.

Categoryđź’€Prepack

Inputs (1)

NameTypeDefaultDescription
value*Input value (string, int, or float)

Outputs (3)

NameTypeDescription
stringSTRINGValue as string
intINTValue as integer (rounded if needed)
floatFLOATValue as float