Nodes/ComfyUI-SimpleLogics/String → Number
ComfyUI Node

String → Number

The permissive parser in the middle

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
String → Number
    • NUMBER
    value0

    String → Number parses a string into a NUMBER, which puts it in a middle ground you'll appreciate once you've wrestled with ComfyUI's type system for a while. It's not as strict as String → Int (no truncation) and not as specific as String → Float (which locks you into a float socket). It just parses the text and hands back the generic numeric type - which is often exactly the permissiveness you want.

    Why you'd reach for it

    Use it when a value arrives as text and the node downstream is flexible about numeric type. A NUMBER socket in ComfyUI is the generic numeric type - under the hood it's a float - and a lot of nodes accept it while only some insist on a specific FLOAT or INT. When you don't know or don't care which one the target wants, converting to the generic NUMBER keeps your options open and lets ComfyUI handle the final coercion.

    Real trigger: reading a parameter out of a settings string or metadata and feeding it onward without locking yourself into one socket type. If the number could legitimately be an integer or a float depending on the workflow run, String → Number sidesteps the question.

    How it works

    Python's float(value) - same permissive-but-strict behavior as the pack's String → Float: whitespace and scientific notation are fine, but non-numeric text like "abc" or "1,5" throws a ValueError and turns the node red. The author's description is minimal: "Parses a string into a NUMBER." Because NUMBER is float-backed, "5" parses to 5.0 internally - so if you're building filenames from it afterward, expect the same .0 you see with the other Number conversions.

    The inputs that matter

    One required input:

    • value - the STRING to parse (defaults to "0")

    One NUMBER output.

    Installing it

    Part of danipisca07/ComfyUI-SimpleLogics, the dependency-free pure-Python pack - no requirements.txt, no models. Install from ComfyUI Manager (search "SimpleLogics") or:

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

    Restart ComfyUI and you're done.

    Common issues

    The failure mode is the same as every string parser: non-numeric input crashes with a ValueError, and comma decimals are the classic silent-ish trap ("1,5" is not valid Python). The bigger practical confusion is choosing between this and String → Float. They parse identically - the only difference is the socket type on the output. If a downstream node stubbornly won't accept a NUMBER, switch to the Float variant; if it accepts both, this one is the more flexible choice. Keep the pack updated with git pull and it'll be fine. (Usual note: the pack also registers an unrelated GeoCalib camera node that the README never documents - ignore it.)

    CategorySimpleLogics/Convert

    Inputs (1)

    NameTypeDefaultDescription
    valueSTRING0

    Outputs (1)

    NameTypeDescription
    NUMBERNUMBER