To Float | Basic
The type adapter that turns ints and strings into floats
- any
- FLOAT
ComfyUI's type system is usually a help - it catches you feeding an INT where a FLOAT is wanted. But sometimes you genuinely have an integer (or a string that happens to be a number) and the downstream node demands a float. That's the whole job of ToFloat ("To Float | Basic"): take a value of any type, convert it to a FLOAT, and hand it out.
The input any is a wildcard - it accepts INT, FLOAT, STRING, BOOLEAN, anything. The conversion logic: numbers convert directly (int → float), and anything else is converted via its string form (float(str(any))), so a string like "2.5" becomes 2.5. If the conversion fails - say you feed it "hello" - it doesn't crash; it quietly returns 0.0. The output is FLOAT.
The inputs that matter
- any - the value to convert. That's it.
Why you'd reach for it
Two main cases. First, type bridging: some node hands you an INT, but the node you're feeding insists on a FLOAT socket - a ToFloat in the middle resolves it without rewriting either side. Second, string-to-number: when a node outputs a numeric string (a parsed value, a token from a text operation), ToFloat turns it into something you can do math with. That's surprisingly common once workflows start juggling text-generated values.
The grace-under-pressure behavior is worth a moment, because it's a deliberate design choice. A failed conversion gives you 0.0 rather than an error, which keeps the graph alive. That's convenient, but it's also how a typo'd string becomes a silent zero downstream. If a value ever seems suspiciously zero, suspect a silent conversion failure somewhere up the chain.
Installing it
Standard pack install - pure Python, zero dependencies:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Basic-Math
Restart ComfyUI, find it under Basic Math ➕ → Conversion as "To Float | Basic". Or use ComfyUI Manager → **Install Custom Nodes → search "ComfyUI-Basic-Math"`.
The gotchas
The silent 0.0 on failure is the main one to remember - there's no error surface, so garbage in quietly becomes zero. Also, this node is the float counterpart of ToInt in the same pack: if you need rounding control (round/floor/ceil/trunc), that's ToInt's domain. And yes, the menu shows "To Float | Basic" - the | Basic suffix is the pack's naming convention.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| any | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |