ComfyUI Node

Convert

The node that fixes ComfyUI's type mismatches

By gitmyloΒ·Created 2 years agoΒ·Updated about a year agoΒ· 13
Convert
  • Input
  • Result
β—„Typeβ–Ύβ–Ί

The most common beginner error in ComfyUI is a red node that says something like "value is not a valid INT" or the vague "input type mismatch." Half the time the fix is one node: FlowNodes' "Convert" takes any value and coerces it to the type you pick. Int, float, string, or boolean - a dropdown and a socket, done.

Why this exists at all: ComfyUI's type system is picky. A node that outputs FLOAT will refuse to plug into a socket that wants INT, even though the value is 3.0 and you clearly meant 3. The graph doesn't know what you meant, so you convert explicitly.

The inputs that matter

  • Type - the dropdown: int, float, str, or bool. Pick your target.
  • Input - a * wildcard socket, so it swallows anything.

Output is Result, also * (wildcard), because the node doesn't know - you do - what type came out. Feed it into whatever socket wants the converted value.

The interesting bit: the bool conversion

Here's where the pack earns a little respect. Python's built-in bool("false") returns True - any non-empty string is truthy - which is a classic footgun. FlowNodes overrides that with a hand-rolled bool that actually reads the value: "0", "false", "False", "FALSE", 0, and False all become False; "1", "true", "True", "TRUE", 1, and True become True. Numbers fall through to a != 0 test.

So converting a string "false" from some dropdown or API response actually gives you False, instead of the lie Python would tell you. That single fix is worth the pack.

The int/float/str conversions are plain Python. Two things to remember:

  • int("12.5") raises - strings must already be integer-shaped. Convert to float first, then int.
  • str(...) on a latent or tensor gives you the object repr, not a useful human string. This node is for scalars, lists, and dicts, not for serializing models.

Where it slots in

FlowNodes is a logic/plumbing pack, so this node's natural friends are its neighbors: an expression node hands you an INT, but the sampler wants a FLOAT; a Regex match gives you strings and you need numbers; a Compare node produces booleans and a filename node wants text. Convert is the adaptor in the middle. It also pairs with the 🐍 Execute Python node - Python is duck-typed, so when your script hands back an unexpected type, Convert is how you normalize it before it hits the rest of the graph.

Install

Part of the FlowNodes pack, no standalone install. ComfyUI Manager β†’ search FlowNodes β†’ install β†’ restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/gitmylo/FlowNodes
# restart ComfyUI

No dependencies, no models. WIP pack, standard caveat.

Troubleshooting

  • Convert to int fails on a decimal string - route through float first. "12.5" β†’ float β†’ int gives you 12.
  • Bool conversion surprises you - remember it accepts "true"/"false"/"0"/"1" strings, which plain Python wouldn't. That's a feature, not a bug.
  • Result type still mismatch - you picked the wrong dropdown entry, or the downstream socket is a stricter subtype. Re-check which Type you chose.
CategoryπŸ”‚ FlowNodes/convert

Inputs (2)

NameTypeDefaultDescription
TypeCOMBO4 options: int, float, str, bool
Input*β€”

Outputs (1)

NameTypeDescription
Result*β€”