Nodes/comfyui-art-venture/String to Number
ComfyUI Node Runs on cloud

String to Number

Turn text into an INT and a FLOAT

By sipherxyz·Created 3 years ago·Updated 4 months ago· 352
String to Number
    • INT
    • FLOAT
    string0
    roundinground

    Small node, obvious job: it takes a string like "7" or "12.5" and gives you back a number you can actually feed into a sampler. Text and numbers are different types in ComfyUI, and a lot of nodes only accept one or the other, so when your value arrives as text - from a JSON field, an API response, an LLM's output, a text box - you need to convert it before it can drive steps, seed, CFG, or dimensions. That's this.

    The reason it exists is the same reason the whole ArtVenture utility set exists: making workflows drivable from data. If a number is hard-coded into a widget, it's fixed. If it comes in as a string you convert on the fly, an external caller can change it every run. StringToNumber is the little adapter that lets text-shaped inputs reach number-shaped sockets.

    How it works

    It parses the input string into a numeric value and emits it in both integer and float form at once. The rounding option decides how the integer output is produced from a fractional value - round to nearest, always down, or always up. The float output keeps the full precision regardless.

    Inputs and outputs

    Two inputs:

    • string - the text to convert, default "0". This is what you wire in from JSON, an API, or a text field.
    • rounding - how to make the integer: round (nearest, the default), floor (down), or ceil (up). Only affects the INT output.

    Two outputs:

    • INT - the rounded integer, for seed, steps, width, height, batch size - anything that demands a whole number.
    • FLOAT - the full-precision value, for CFG, denoise, LoRA strength, and other continuous settings.

    Handy that it gives you both - you wire whichever the target socket wants without a second conversion node.

    Installing it

    Part of the ArtVenture pack. ComfyUI Manager: search comfyui-art-venture, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sipherxyz/comfyui-art-venture
    

    Restart ComfyUI. No downloads - pure Python, instant load.

    Common issues

    It errors or returns 0 on messy input. The string has to actually look like a number. Stray currency symbols, commas as thousands separators, units, or leftover whitespace can trip the parse. Clean the text upstream - pull just the numeric field out of your JSON rather than converting a whole sentence.

    Wrong integer value. Check the rounding mode. floor on 2.9 gives you 2, ceil gives 3, round gives 3. If your steps count is coming out one lower than expected, that's usually floor doing exactly what you told it.

    Decimals got truncated. You wired the INT output where you wanted the FLOAT. For denoise, CFG, or strengths, take the FLOAT output - the INT has already dropped the fractional part.

    A negative or huge number sails through. The node converts what you give it; it doesn't sanity-check ranges. If a bad upstream value could produce nonsense (negative steps, an absurd resolution), clamp it before or after with a math/clamp node rather than trusting the source.

    CategoryArtVenture/Utils

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING0
    roundingCOMBOround3 options: round, floor, ceil

    Outputs (2)

    NameTypeDescription
    INTINT
    FLOATFLOAT