ComfyUI Node

to FLOAT

The 'please be a decimal' node

By StableLlama·Created about a year ago·Updated 4 days ago· 48
to FLOAT
  • input
  • FLOAT

Every ComfyUI user hits the moment where a node wants a FLOAT and the value in your graph is an INT, or worse, a string that looks like a number. ComfyUI's sockets are typed, and the polite thing is to convert explicitly - which is what to FLOAT does. One input, one float out, and it's the node you'll use constantly once you're wiring math into filenames, prompts, and conditioning.

It's part of Basic data handling, StableLlama's zero-dependency pack. The cast nodes are the unglamorous backbone of the pack: you won't post about them, but every workflow that mixes numbers and strings quietly depends on them.

How it works

The conversion is Python's float(input), which accepts a handful of things:

  • numbers - an INT or a FLOAT passes through, an INT becoming e.g. 33.0
  • numeric strings - "3.5", "-2", "1e3" all parse fine
  • True1.0, False0.0

Anything else raises a ValueError with a clear message. Note that float() is strict about what it parses: "3,5" (comma decimal) raises, and whitespace-adjacent strings like "3.5 kg" fail too. If you're converting text that came from a file or a custom node, you may need to clean it first with a string node.

The input and the output

  • input (ANY) - the number or numeric string to convert.
  • FLOAT (output) - the converted value.

One in, one out. Wire it between a string-producing node and anything that demands a FLOAT socket.

Installing it

Install Basic data handling via ComfyUI Manager (search "Basic data handling"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI. No dependencies, no models - a clean, safe install.

Troubleshooting

  • "It says 'Cannot convert' on a number-looking string." Usually a formatting problem: a comma decimal ("3,5"), a trailing unit, or surrounding spaces. The cast is strict by design. Strip and clean the string first, or fix it upstream.
  • "I wanted rounding, not casting." Casting doesn't round - float(3) is 3.0, and casting a string like "3.14159" keeps all the digits. If you want to round to fewer decimals, that's the pack's round node. Different job.
  • "INT in, FLOAT out - is this even doing anything?" Yes - it's retyping so the socket connection is legal and downstream math behaves as float math. It matters more than it looks like it matters.
CategoryBasic/cast

Inputs (1)

NameTypeDefaultDescription
input*

Outputs (1)

NameTypeDescription
FLOATFLOAT