ComfyUI Node

Mpi Convert

One value in, every type out

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi Convert
  • input
  • STRING
  • INT
  • FLOAT
  • BOOLEAN
roundtrue

ComfyUI is strict about socket types, and that's usually a feature - until you've got one number that needs to be a FLOAT for one node, an INT for another, and a string for a filename. That's the entire job of MpiConvert. It takes any value in and gives you STRING, INT, FLOAT and BOOLEAN outputs all at once, so you wire whichever one you need and ignore the rest.

How it works

The mechanism is deliberately simple. If the input is a string, it's parsed with float() first - so "42" becomes a number, not a type error. Then it rounds, and this is the part most people miss:

  • round on (the default, labelled "up") uses ceil - 3.1 becomes 4.
  • round off ("down") uses floor - 3.9 becomes 3.

The INT output is that rounded value, the FLOAT is it as a float, the STRING is its string form, and the BOOLEAN is its truthiness (anything non-zero is true). So MpiConvert on 3.7 with round on gives you 4, 4.0, "4", and true on the four sockets. One run, four ready-to-wire values.

The inputs that matter

Just two:

  • input - anything: a float from a strength slider, an int from a size node, even a numeric string.
  • round - the up/down toggle. Leave it on unless you specifically want values truncated instead of rounded.

Where people get burned

Two gotchas, both real.

First: the string parse is float(), not a general text converter. Feed it "hello" and it throws - this node converts numeric text, not arbitrary strings. If you're passing text around to be displayed or saved, you want a pass-through node, not this.

Second: the BOOLEAN is truthiness of the rounded number. 0.4 with round on goes to... wait, ceil(0.4) is 1, so the boolean comes out true even though the original value was nearer zero. If you're using this as a "is the value non-zero" check, that's a trap. For a strict emptiness check, use MpiAnyChecker or MpiConvert with round off - floor(0.4) is 0, false. Small detail, but it has bitten people chasing phantom branches.

Install

From the MadPonyInteractive/ComfyUi-MpiNodes pack - ComfyUI Manager → search ComfyUi-MpiNodes (publisher mad-pony-interactive), or:

cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes

then restart. Pure Python, no dependencies, no model files. The pack is AGPL-3.0 (≤ 1.2.6 MIT) and doubles as the node engine for the author's Cubric Vision app.

When you'd actually reach for it

The sweet spot is anywhere a value crosses type boundaries: a float strength that needs to become an int for a count, a seed that needs a string for a filename prefix, a computed number that has to gate a boolean branch. It's the kind of node you don't notice until you need it, then you reach for it constantly. If your workflow only ever feeds FLOAT into FLOAT, you can skip it - but the moment a single value fans out into three typed sockets, this is the cleanest way to do it.

CategoryMpiNodes/Logic

Inputs (2)

NameTypeDefaultDescription
input*
roundBOOLEANtrue

Outputs (4)

NameTypeDescription
STRINGSTRING
INTINT
FLOATFLOAT
BOOLEANBOOLEAN