Nodes/ComfyUI Fictiverse Nodes/Any to Int/Float/String
ComfyUI Node

Any to Int/Float/String

The converter that shrugs and tries anyway

By Fictiverse·Created 3 years ago·Updated 23 days ago· 27
Any to Int/Float/String
  • value
  • as_int
  • as_float
  • as_string

Any to Int/Float/String takes one input of any type at all - the socket accepts anything - and hands you three outputs: the value as an integer, as a float, and as a string. It's the conversion node you pull out when a node upstream is being stubborn about what type it emits, and you need a different type to satisfy a downstream socket.

ComfyUI is surprisingly strict about types. An INT socket won't accept a FLOAT wire without a conversion node, a string that looks like a number is still a string, and a node that returns a weird custom type can leave you staring at a red socket with no obvious way in. This node is the universal adapter for exactly that moment. The "Any" part of the name isn't marketing - the input is typed as a wildcard, so ComfyUI lets you connect anything to it without type complaints.

How it works

It's three try blocks doing exactly what you'd expect:

  • as_int - tries int(value). If that fails, you get 0.
  • as_float - tries float(value). If that fails, you get 0.0.
  • as_string - tries str(value). If that fails, you get an empty string.

The "shrug" is the design: nothing here throws. Feed it a tensor, a list, a dict, a string like "42", a float - you always get three usable outputs. The failure fallbacks are the catch: if the conversion isn't possible you silently get 0 / 0.0 / "" rather than an error, and that can mask a problem if you're not watching. "42abc" becomes int 0 - which might be exactly what you want from a defensive node, or might be a bug you're about to chase for an hour.

A practical note: converting a string like "3.7" gives you as_int = 3 (int truncates), as_float = 3.7, and as_string = "3.7". And as_string of a float keeps its Python repr - 1.0 stays "1.0", not "1".

Inputs and outputs

  • value (*) - the wildcard input. Anything goes.

Outputs:

  • as_int (INT)
  • as_float (FLOAT)
  • as_string (STRING)

Wire the one you need forward; the other two are free side outputs.

Where you'd use it

The classic case is a node that returns a string where you need a number - some text nodes, CSV readers, filename builders, nodes that give you "512" and expect you to feed an Empty Latent Image. Drop this in the middle and you're done. It's also handy for debugging: you can string-ify something opaque and stick it in a preview or text display to see what's actually flowing through a wire.

Installing it

Ships in ComfyUI Fictiverse Nodes. ComfyUI Manager → search "ComfyUI Fictiverse Nodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Fictiverse/ComfyUI_Fictiverse

No dependencies, no models. Apache 2.0.

Common issues

The pack's startup error - ModuleNotFoundError: No module named 'custom_nodes.ComfyUI_Fictiverse' - means the folder isn't named exactly ComfyUI_Fictiverse; rename and restart.

For this node, the trap is the silent fallbacks. If you rely on as_int from a string that isn't parseable, you'll get 0 without any warning - that's often a red zero hiding in a workflow doing math. When something downstream looks wrong and this node is in the chain, check what's actually coming into value first; the bug is usually upstream, and this node is just politely converting the garbage.

CategoryFictiverse/Utils

Inputs (1)

NameTypeDefaultDescription
value*

Outputs (3)

NameTypeDescription
as_intINT
as_floatFLOAT
as_stringSTRING