ComfyUI Node

Any Cast

Any Cast relabels wires more than it converts values — and that's fine

By var1ableX·Created 2 years ago·Updated 11 months ago· 1
Any Cast
  • ANY
  • *
TYPE

Any Cast is the node you grab when ComfyUI won't let you plug a red wire into a blue socket. ComfyUI is picky about types - an INT seed won't go into a FLOAT port, a BOOLEAN won't feed a STRING input - and Any Cast sits in between as a universal adapter, telling the graph "trust me, this is the type you asked for."

But let's be straight about what it actually does, because the name oversells it. Looking at the source, only four of the sixteen TYPE options do any real conversion: STRING (str(x)), INT (int(x)), FLOAT (float(x)), and BOOLEAN (x > 0 for numbers, truthiness for everything else). The other twelve - IMAGE, LATENT, MASK, MODEL, CLIP, VAE, CONDITIONING, NOISE, SAMPLER, SIGMAS, GUIDER, and "*" - are pure passthrough. The value comes out exactly as it went in; the node just re-declares the wire's type so it'll connect where a specific type is demanded. That's genuinely useful, it's just not magic.

How it works

The ANY input accepts literally anything, thanks to the wildcard trick - the source credits pythongossss, the any-type-string pattern that lets one input accept every type. You pick a target from the TYPE dropdown, the node runs its cast helper, and out comes the value typed as *. Because the output is any-type, it plugs into whatever port you aimed it at.

Inputs and outputs

Two required inputs: ANY (whatever you've got) and TYPE, a dropdown with the sixteen targets above. One output: the value, typed as *. For a beginner, the practical moves are INT → FLOAT when a node insists on floats (seeds are ints; sampler parameters are often floats), and BOOLEAN → STRING or INT when you want to turn a true/false from something like this pack's Is Image Empty or Is Mask Empty into text or a number for display or math.

Where people get burned

The boolean cast uses "greater than zero," not "non-zero" - negative numbers cast to False. And int()/float() on a genuinely non-numeric string raises an error mid-run; the node can't rescue garbage in. Most importantly: casting an INT to IMAGE gives you the same integer back, not a picture. Passthrough means passthrough - don't expect conversions for anything that isn't a scalar.

Install

Same tiny pack, same steps. ComfyUI Manager → search "ComfyUI_Accessories" → Install, then restart, or:

cd ComfyUI/custom_nodes && git clone https://github.com/var1ableX/ComfyUI_Accessories

No dependencies, no model files. Once it loads, Any Cast needs no setup beyond picking a TYPE.

Common issues

The one that affects every node here: the current GitHub head has a broken import - GetRandomDimensions was removed from nodes.py but is still imported in __init__.py, so the entire pack fails to load until you wait for a fix or delete that one import line. After that, Any Cast behaves, with the caveats above. If you're casting to a type that isn't one of the four scalars, remember you're getting a relabel, not a conversion - and if the value still won't connect, the problem is usually that a passthrough of the wrong underlying data can't save you.

CategoryAccessories

Inputs (2)

NameTypeDefaultDescription
ANY*
TYPECOMBO16 options: *, STRING, INT, FLOAT, BOOLEAN, IMAGE, +10

Outputs (1)

NameTypeDescription
**