ComfyUI Node

String to Float

When text says '3.5' but you need the number 3.5

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
String to Float
    • float_value
    value0.0

    The number on a screen is not the number in a node. ComfyUI is strict about types, and when a string "3.5" comes out of a text node or a config loader, the KSampler on the other end just stares at you. String to Float parses a text string into a real FLOAT so you can wire it into math, sliders, or sampling parameters. It's the "make text numeric" glue node.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. The mechanism is a single float(value) call wrapped in error handling.

    How it works

    One required input:

    • value - the STRING to parse (default "0.0", single-line)

    One output: float_value - the parsed number as a FLOAT.

    The node calls Python's float() on the string. That handles the expected forms: "3.5"3.5, "-0.25"-0.25, "1e3"1000.0, and even whitespace-padded input. If the string isn't a number, it raises a ValueError with a message like Cannot convert 'abc' to float - so garbage fails loudly rather than silently, which is the right call for a conversion node.

    Where you'll use it

    • Config files and wildcards. A text file or text node holds a CFG or strength as a string; convert it here before it touches anything mathematical.
    • Text-switch outputs. Conditional string nodes give you text; if what you selected is actually a number, this is the back-conversion.
    • Feeding math. Run the float into Number Clamp, Number Remap, or the pack's math nodes for further processing.

    Installing it

    Whole pack, one install. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. Requirements (numpy, torch, opencv-python) are already satisfied by stock ComfyUI; no models to download. When searching Manager, don't confuse this pack with cubiq's "ComfyUI Essentials" - a different, larger pack that's in maintenance mode.

    Gotchas

    • It raises on bad input. Unlike the pack's String to Boolean (which never fails and defaults to True), this node will throw a ValueError and can halt execution if the string isn't numeric. That's a feature - you'll know immediately - but it means sanitize text before wiring it in.
    • Locale quirk: a comma as decimal separator ("3,5") will fail on most systems. If you're parsing European-format numbers, normalize the comma to a dot upstream.
    • Empty string raises too - there's no default-coercion here.
    • It's a small pack with little community footprint; the behavior is plain enough that the source is the doc.
    CategoryDebugPadawan/Conversion

    Inputs (1)

    NameTypeDefaultDescription
    valueSTRING0.0

    Outputs (1)

    NameTypeDescription
    float_valueFLOAT