Nodes/comfyui_bmad_nodes/String to Float
ComfyUI Node Runs on cloud

String to Float

The float twin of String to Integer, for when your API sends decimals as text

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
String to Float
    • FLOAT
    inStr

    String to Float is String to Integer's sibling, and it exists for the exact same reason: API requests keep handing you text where a number belongs. It takes a STRING like "7.5" and returns a FLOAT - the type ComfyUI's denoise, CFG, and strength sockets all want.

    The context is identical to its integer twin. When you drive ComfyUI from a script via the /prompt endpoint, or use this pack's RequestInputs node to pass parameters in from a JSON body, values arrive as strings. A denoise of 0.75 from your frontend shows up as "0.75", and the FLOAT socket refuses it. This node is the float(inStr) adapter that fixes the type mismatch - one Python call, no magic, no model.

    It lives under Bmad/api/parseInput next to String to Integer and Input/String to Int Array, and it has exactly one input and one output worth caring about:

    • inStr - the string to parse. Feed it "0.75" and you get 0.75.
    • Output: FLOAT, ready for any float socket - CFG, denoise, LoRA strength, sampler noise, you name it.

    Install

    Both parse nodes ship in bmad4ever/comfyui_bmad_nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_bmad_nodes
    cd comfyui_bmad_nodes
    pip install -r requirements.txt
    

    Restart, or use ComfyUI Manager → "Install Custom Nodes" → search comfyui_bmad_nodes. The pack's dependencies (opencv-python~=4.8.1.78, scikit-image, gray2color, simpleeval) install fine even though a float parser touches none of them. No model downloads anywhere in this pack.

    Gotchas

    Parsing is strict Python float(), so the string has to be a valid float. "7.5" and "7" both work (the latter becomes 7.0); "7,5" (European decimal comma), "abc", and "" all raise a ValueError and kill the workflow. This is actually the one place to be careful with how your request body formats decimals - send dots, not commas. And remember this node's output is a float, so don't wire it into an INT socket expecting magic; for whole numbers, use its integer twin instead.

    CategoryBmad/api/parseInput

    Inputs (1)

    NameTypeDefaultDescription
    inStrSTRING

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT