Nodes/ComfyUI CoolB Nodes/CB Data type Converter ⚡️
ComfyUI Node

CB Data type Converter ⚡️

The node that turns \"7\" into 7, and quietly into 0 when it can't

By CoolBreeze164·Created 29 days ago·Updated 21 days ago· 2
CB Data type Converter ⚡️
  • value
  • converted_value
◄output_typeSTRING►

Why a "convert any type" node exists at all

ComfyUI's type system has exactly one escape hatch: the wildcard type *, which the docs call ANY and describe as an input you can wire anything into. A node that declares its input as * is promising to make sense of whatever lands there - model, latent, string, tensor, a dict.

That's the socket this node is built around, and it's the reason it shows up in plumbing-heavy graphs. The values in your workflow arrive in the wrong flavour constantly. CB Read Text File hands you a string and the sampler wants an INT. A Telegram or API node hands you the string "true" and your gate wants a real BOOLEAN. Something upstream emits a number and you want it in a log line. Core's Primitive and PrimitiveInt/PrimitiveFloat nodes define a value, but they don't cast one - if the type is wrong, they just don't connect. This is the adapter for when you need the conversion, not just the container.

How it converts - the whole mechanism, because it's about thirty lines

You get one input and one dropdown, and the dropdown decides everything:

  • STRING → str(value). Anything goes, including whatever Python's repr of a tensor looks like. Genuinely handy for debugging, useless as a prompt.
  • FLOAT → float(value), and if that raises, you get 0.0.
  • INT → int(float(value)). The float-first step is deliberate, which is why "3.14" becomes 3 instead of throwing a ValueError.
  • BOOLEAN → if the value is a string, only "true", "1", "yes" and "on" (lowercased and trimmed first) count as True. Everything else is False. Non-strings just go through bool(value).

That last one is the bit people get wrong in both directions. A node that returns the string "False" converts to... False, correctly, since it isn't in the True list. But "y", "enabled", "1.0" and "TRUE " - well, that last one works, the rest are False.

The trap: it never complains

Failed conversions don't raise. They return 0 or 0.0 or False and move on. So a typo in a config file doesn't blow up your run - it sets your step count to zero or disables a branch, and you find out three nodes later. There is also no type checking on the way out: the output is declared as *, so ComfyUI will let you plug your "converted" boolean straight into an INT input.

Wire converted_value into any input you've converted from a widget - right-click the widget on the KSampler, choose Convert widget to input, then plug this in. That's the whole flow: text file → converter → steps. Read the value it emits once with a preview or a text box before you trust it in a long graph.

Inputs and outputs

| | | |---|---| | value (*, required) | the thing you want converted | | output_type (enum: STRING, FLOAT, INT, BOOLEAN) | the only knob that matters | | converted_value (*, output) | the converted primitive, typed loosely on purpose |

Installing it

ComfyUI Manager → Custom Nodes Manager → search ComfyUI CoolB Nodes → Install → restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/CoolBreeze164/ComfyUI-CoolB-Nodes

Nothing else to fetch. The pack ships no requirements.txt, and its torchaudio/av/numpy imports all sit inside try/except blocks - the README is telling the truth when it says av, numpy and torchaudio come with ComfyUI already.

Common issues

A widget mysteriously became 0 or 0.0. That's the silent fallback, not a bug. Check what actually arrived on the value socket - a leading space, a comma used as a decimal separator, or a word where a number was expected all produce zero.

Digits from a text file, in bulk. Anything the converter can't parse becomes 0 rather than stopping the run, so if you're driving four different widgets off one config file, all four read 0 and nothing tells you which line was at fault.

Unexpected False. The True list is short: true, 1, yes, on. For anything else - including a check mark, an emoji, or the word "enabled" - write the comparison yourself upstream.

Nobody has hit this before you. This pack is tiny and essentially undiscussed; there is no forum thread to lean on. The upside is nodes.py is short and readable, so when behaviour surprises you, read AnyToPrimitive.convert - it's fifteen lines and it's the whole story.

CategoryCoolB Nodes ⚡️

Inputs (2)

NameTypeDefaultDescription
value*—
output_typeCOMBOSTRING4 options: STRING, FLOAT, INT, BOOLEAN

Outputs (1)

NameTypeDescription
converted_value*—