Nodes/ComfyUI-JDCN/LogicUtil_Convert to String
ComfyUI Node

LogicUtil_Convert to String

Any input to text — the node that silences 'expected STRING'

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Convert to String
  • input1
  • STRING

LogicUtil_ConvertAny2String takes any input and returns its string form. Feed it an integer, a float, a boolean, a path - out comes text. In ComfyUI's loosely-typed world this looks trivial, and it kind of is. But "trivial" is exactly what you want when a text node refuses to accept an INT, or when you need a number in a filename, or when you're building a string for a message or a save path.

How it works

One required input, input1, typed as * (any). The conversion is just Python's str(), so you get a human-readable text version of whatever you feed it: 42"42", 3.5"3.5", True"True". The single output, STRING, is a plain string you can wire into any text-accepting node.

It's part of the small LogicUtil suite bundled with this pack (converters, math helpers, logic gates, plus the deliberately-failing LogicUtil_ErrorNode). Same idea as the pack's other convert nodes - ConvertAny2Int, ConvertAny2Float, ConvertAny2Bool exist as siblings - but string is the one that gets used constantly, because so much of ComfyUI's glue is text.

When it earns its place

  • A JDCN_BatchCounter gives you an INT for a lap number; you want it in a filename prefix. Convert, then concatenate into a path for JDCN_TXTFileSaver or a save node.
  • A math node's output needs to go into a ShowText / preview node that only accepts strings.
  • You're assembling an error message or a debug string for a logic workflow and need a number as text.

One honest caveat: it converts, it doesn't format. No padding, no %02d zero-fill, no rounding control. If you need frame_0007 style filenames, you'll want to do that formatting in the source (or patch the string afterward) rather than expecting this node to pretty-print.

Installing it

It ships inside ComfyUI-JDCN, so:

  • ComfyUI ManagerInstall Custom Node → search JDCN → install ComfyUI-JDCN → restart.
  • Or:
cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN.git
cd ComfyUI-JDCN
pip install -r requirements.txt

Restart, and it appears under LogicUtil in the node menu (not the blue JDCN category - the two are grouped separately even though they install together). Only dependency is piexif.

Common issues

The main gotcha is the same one that bites every auto-conversion: the string you get back may not round-trip. A float 1.0 becomes "1.0", which a node expecting a plain integer string may choke on. If you're converting to feed a filename, double-check the intermediate form. Otherwise it's a reliable, side-effect-free utility - the sort of node you install once, forget about, and quietly depend on forever.

CategoryLogicUtil

Inputs (1)

NameTypeDefaultDescription
input1*0

Outputs (1)

NameTypeDescription
STRINGSTRING