ComfyUI Node

Any Convert

Force any value into the type a widget actually wants

By wenchengxiang·Created 2 months ago·Updated 9 days ago· 3
Any Convert
  • any
  • out
◄output_typecombo►

ComfyUI's type system is rigid in a way that's both its safety net and its biggest annoyance: a STRING socket won't accept an INT wire, no matter how obviously "42" is a number. Half the "wrong type" errors in a beginner workflow come from exactly this. Any Convert is the coercion hammer - it takes any value and converts it to the type you pick, so you can stop fighting sockets and just make the value fit.

Inputs:

  • any - the value to convert, wildcard type
  • output_type - a dropdown with five choices: combo, string, int, float, boolean (defaults to combo)

The output is out, which adopts whatever type you selected. The mechanism, straight from the source, is a thin wrapper over Python's own conversions: combo passes the value through untouched, string is str(any), int is int(any), float is float(any). The interesting one is boolean, which is deliberately strict - it only accepts 0/1 as ints, 0.0/1.0 as floats, and "0"/"1" as strings, and raises ValueError on anything else. That's the right call, honestly. Most nodes would silently apply Python truthiness and turn the string "false" into True without a word; this one refuses to guess, and a loud error beats a silently wrong branch every time.

Where you actually use it:

  • An INT seed or step count that needs to become a STRING for a filename or a Text node.
  • A numeric value feeding a widget that only accepts FLOAT.
  • Any place you're building conditional logic and the type at the socket doesn't match the type upstream.

Two things to know before you drop it everywhere:

  • int and float raise on non-numeric input. Converting "abc" to int throws a ValueError at run time. The wildcard socket means ComfyUI won't warn you at connection time, so garbage in becomes an exception mid-run. If you're converting arbitrary text, wrap it upstream.
  • The author marked this node OUTPUT_NODE = True. In ComfyUI that means it's treated as an output node, so it always executes even when its output feeds nothing - a small performance footnote, not a bug, but it's a reason to keep a handful of these around rather than scattering them across every socket.

Install is the pack standard: ComfyUI Manager → search ComfyUI-Practical-Tools → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools

No dependencies, no models, no key. If a run dies with a ValueError in a conversion, it's almost certainly this node being strict on purpose - feed it 0/1, not "true", and you're set.

CategoryPractical-Tools/utils

Inputs (2)

NameTypeDefaultDescription
any*—
output_typeCOMBOcombo5 options: combo, string, int, float, boolean

Outputs (1)

NameTypeDescription
out*—