Nodes/ComfyUI-SimpleLogics/String → Float
ComfyUI Node

String → Float

Parse text into something math can use

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
String → Float
    • FLOAT
    value0.0

    String → Float parses a string into a float, which is the reverse of every conversion you've seen so far. It exists because ComfyUI's text world and number world are strictly separated: if a node hands you a number as a string - a value pulled out of a filename, a caption, a metadata field, or a text file - you can't do math on it until you convert it. This is that conversion.

    Why you'd reach for it

    The most common trigger is reading a value that arrived as text. You loaded a saved workflow's parameters from a JSON or text node. An OCR or metadata node pulled a number out of a caption. A filename contains a seed you want to reuse. All of those arrive as STRING, and every numeric input socket in ComfyUI wants an actual number. String → Float is the bridge.

    It's also how you make text inputs parameters. If you've built a workflow where a user types a CFG or a denoise strength into a text box, the pipeline needs to parse that text before the sampler will accept it. Same idea for batch counts pulled from a settings string.

    How it works

    Python's float(value), which is permissive in specific ways: leading and trailing whitespace is fine, and scientific notation works, so " 2.5 " and "1e3" both parse (the latter to 1000.0). But it's strict about the actual text - "abc" or "1,5" (comma decimal) will throw a Python ValueError, which in ComfyUI shows up as a red node and an error in the console. The author's description is just "Parses a string into a float." The pack's sibling String → Int uses int(float(...)), so it also accepts decimal text but truncates - this node keeps the fractional part.

    The inputs that matter

    One required input:

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

    One FLOAT output, ready for any float socket - denoise, CFG, upscale factor.

    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 one real failure mode is a non-numeric string, and it's worth understanding because it's the only way this node goes red: "3.5" parses fine, but "3,5", "3.5x", or a label like "strength: 3.5" will crash with a ValueError. If you're parsing text that might have extra words or symbols, strip those before you hit this node - a String Replace or similar upstream is your friend. Everything else about a float() call is boring and reliable. (And the usual pack note: it also registers an unrelated GeoCalib camera node the README never mentions - ignore it.)

    CategorySimpleLogics/Convert

    Inputs (1)

    NameTypeDefaultDescription
    valueSTRING0.0

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT