ComfyUI Node

String to Float

Parse a number out of a text field

By jamesWalker55·Created 3 years ago·Updated 4 days ago· 218
String to Float
    • FLOAT
    text0.0

    Sometimes a number arrives as text and you need it as an actual number. Maybe it came from a filename, a piece of metadata, a text field you're driving from outside, or another node that only outputs strings. JWStringToFloat reads a STRING and gives you back a FLOAT you can wire into anything that expects a decimal - CFG, denoise, a LoRA weight, a strength.

    It's a small bridge node, and it exists because ComfyUI is strict about types: a socket that wants a FLOAT won't accept a STRING, even if that string plainly reads 0.75. This node does the parsing so the connection is legal.

    How it works

    It takes the text and interprets it as a floating-point number - the way Python's float() would. "0.75" becomes 0.75, "3" becomes 3.0, "-1.5" becomes -1.5. The text needs to actually look like a number; that's the one requirement.

    The inputs and outputs that matter

    • text (STRING) - the text to parse. Default "0.0". Wire in a string from another node, or type a value directly.
    • Output: FLOAT - the parsed number, ready for any float socket.

    There's genuinely nothing else to set. One string in, one float out.

    How to install it

    Ships in jamesWalker55/comfyui-various, a pack of small utility nodes.

    • ComfyUI Manager: search "Various ComfyUI Nodes by Type", install, restart. Red node from someone's workflow? Install Missing Custom Nodes finds it.
    • Manually:
      cd ComfyUI/custom_nodes
      git clone https://github.com/jamesWalker55/comfyui-various
      
      Restart after. No models, no dependencies.

    It'll be under the jamesWalker55 category once ComfyUI restarts.

    Common issues

    • It errors on text that isn't a number. This is the big one. If the string has letters, currency symbols, stray spaces, or a comma decimal separator ("0,75" instead of "0.75"), the parse fails and the node throws. Make sure whatever feeds it is a clean numeric string. If you're pulling a number out of a messier string, clean it up with a string-manipulation node first.
    • You have text with a whole number and wanted an INT. This node always produces a FLOAT. If the downstream socket needs an integer, chain a JWFloatToInteger after it and pick your rounding mode.
    • Node is red / missing. The pack isn't installed. Install via Manager or clone the repo, then restart ComfyUI fully.

    Think of it as the inverse of JWFloatToString: one turns a number into text for display or filenames, this one turns text back into a number you can compute with.

    CategoryjamesWalker55

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING0.0

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT