ComfyUI Node

Number to String

Numbers as text, without the 0.30000000000000004

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Number to String
    • string_value
    value0.00
    decimal_places2

    Every filename, label, and metadata string you build eventually needs a number turned into text. Number to String does that conversion with one thing the built-in string conversion won't give you: control over the decimal places. Want 3.14 instead of 3.141592653589793? Want a whole number without a trailing dot? This is the node. If you've ever saved a file as strength_0.30000000000000004.png, you know exactly why this exists.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. No models, no GPU - this is a format string in a box.

    How it works

    Two required inputs:

    • value - the number to convert (FLOAT, default 0)
    • decimal_places - how many digits after the decimal point, 0–10 (default 2)

    One output: string_value - the number as a clean STRING.

    The implementation splits on decimal_places == 0: that case converts via str(int(round(value))), so 3.7 becomes "4" and 3.2 becomes "3" - no decimal point at all. Otherwise it formats with f"{value:.2f}"-style precision, which is what keeps the string clean rather than dumping raw float noise.

    Where you'll use it

    • Filenames. Build a save name like final_cfg_{cfg}_seed_{seed}.png by converting each numeric parameter to text first and feeding them into the pack's Text Joiner or a string formatter.
    • Labels and captions. Feed the string into a text display or Debug Print for human-readable output.
    • Metadata. Any downstream node that writes text - workflows, tags, info panels - wants a string, and this is the disciplined way to get one.

    Installing it

    One install, whole pack. 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 are numpy, torch, and opencv-python - all already in a stock ComfyUI install - and there are no model downloads. Watch out in Manager's search: this is DebugPadawan's ComfyUI Essentials, not cubiq's "ComfyUI Essentials," a different pack that's now in maintenance mode.

    Gotchas

    • Banker's rounding again. The zero-decimal case uses Python's round(), which rounds half-to-even - 2.5 becomes "2". If you need .5 to always go up, you'll want Number Round plus a different path.
    • It truncates by format, not by rounding at higher precision - that's the same Python float rounding behavior, so 2.675 with two decimals can give "2.67". Standard float weirdness, not a node bug.
    • The input is FLOAT; if you're converting an INT from a node that only hands out ints, it coerces fine.
    • Small pack, quiet community - for a node this mechanical, you won't find much forum chatter, and you won't need it.
    CategoryDebugPadawan/Conversion

    Inputs (2)

    NameTypeDefaultDescription
    valueFLOAT0.00
    decimal_placesINT20–10

    Outputs (1)

    NameTypeDescription
    string_valueSTRING