Nodes/ComfyUI Level Pixel/Convert String To Number [LP]
ComfyUI Node

Convert String To Number [LP]

Get both the float and a rounded int from one string, one node

By LevelPixel·Created 2 years ago·Updated 5 months ago· 31
Convert String To Number [LP]
    • INT
    • FLOAT
    string
    round_integer

    The more capable sibling of Convert String To Int: where that node hands you a whole number and nothing else, this one parses a string as a number and gives you both an INT and a FLOAT back from a single node - genuinely handy anywhere downstream needs the precise value in one place and a rounded whole number in another, without duplicating the conversion.

    What it does

    Feed it a string and it parses it as a numeric value. Unlike its sibling, this node exposes an actual choice for how the integer version gets rounded, via a dropdown: round, round down, or round up. That control is the whole reason to reach for this node over the plainer Convert String To Int whenever there's any chance the source string has a decimal point - a value computed elsewhere and stringified, a measurement, anything that isn't guaranteed to already be a clean whole number.

    Inputs and outputs that matter

    • string (required, single-line, defaults to empty) - the text to convert.
    • round_integer - a dropdown with three choices: round (standard nearest-value rounding), round down (always truncate toward zero/floor), round up (always ceiling). This only affects the INT output; the FLOAT output carries the full precision regardless of what you pick here.

    Two outputs: INT, rounded according to your chosen mode, and FLOAT, the unrounded value. Wire whichever one the next node actually needs - you don't have to use both.

    Installing it

    Through ComfyUI Manager, search "ComfyUI Level Pixel" or "ComfyUI-LevelPixel." Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git
    

    Restart ComfyUI. No models or extra dependencies.

    Where people get burned

    The main thing to watch is picking the right rounding mode for the situation and not just leaving it on the default. round down and round up behave predictably in one direction each, which matters if you're computing something like a batch size or a dimension where consistently rounding one way (never exceeding a limit, or never underfilling a batch) is the actual requirement - the plain round option can go either direction depending on the value, which is fine for display but can cause subtle off-by-one issues if a downstream node is strict about a boundary.

    And same caution as its sibling node: if the input string isn't numeric at all - empty, or text that never was a number - there's no widget here for a fallback value, so treat the upstream source of that string as the thing to check first if this node is producing unexpected results deeper in a graph you're debugging.

    CategoryLevelPixel/Conversion

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    round_integerCOMBO3 options: round, round down, round up

    Outputs (2)

    NameTypeDescription
    INTINT
    FLOATFLOAT