ComfyUI Node

FTOA

Float to text, with the decimal places you actually want

By exectails·Created 2 years ago·Updated 7 months ago· 3
FTOA
    • text
    value0.00
    decimals3

    The decimals argument is the whole reason this node exists. Converting a float to text in ComfyUI is easy - doing it with the number of digits you actually want in the output is the part that makes FTOA worth installing. If you've ever seen a CFG value come out as 7.000000000000001 in a prompt, you know exactly why this matters.

    What it does

    Takes a FLOAT and turns it into a STRING with a fixed number of decimal places. Default is 3 decimals, so 0.0 becomes "0.000", and 1.5 becomes "1.500". Fixed-point, not "smart" - it always prints exactly the digit count you ask for.

    How it works

    The source is "{:.{}f}".format(value, decimals) - Python's fixed-point float formatting. A couple of consequences worth internalizing:

    • It rounds, it doesn't truncate. With decimals=2, 0.999 becomes "1.00". (It follows Python's normal float rounding rules, so binary-representation quirks can show up at the boundary - that's a Python thing, not a bug in the node.)
    • The digits are fixed. decimals=3 gives you "0.000" for zero, trailing zeros and all. If you want "0", set decimals=0.
    • Range limits: decimals goes 0–8, and value is bounded to roughly ±2 billion. Neither limit is something you'll trip over in practice.

    Inputs:

    • value (FLOAT) - the number to convert. Default 0.
    • decimals (INT) - digits after the point, 0–8, default 3.

    Output: text (STRING).

    Why you'd actually use it

    The killer pattern is embedding numbers into prompts. Chain FTOA into the pack's Text Formatter and build things like "35mm f/{arg0} portrait" - where a CFG value, a denoise strength, or a LoRA weight from elsewhere in your graph becomes readable text in the prompt. It's also handy for labels and filenames when something downstream only takes strings.

    How to install it

    From exectails/comfyui-et_stringutils ("String Utils"). ComfyUI Manager → search "String Utils", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/exectails/comfyui-et_stringutils
    

    Restart, find it under exectails/Strings. No requirements, no model downloads - pure stdlib.

    Common issues

    • Trailing zeros surprise people. "1.500" looks odd the first time, but it's the correct output for decimals=3. If that bothers you, drop to 0–2 decimals.
    • Don't expect scientific notation - no 1e-7 handling here, it's plain fixed-point.
    • Pair it with ITOA for the sibling problem - ITOA does the same job for integers, and ATOI goes the other direction (string to int). This pack covers both halves of the number↔text trip.

    One caveat: FTOA gives you text. If your downstream truly needs a number, this is a dead end - but for anything that consumes strings, it's exactly the right tool.

    Categoryexectails/Strings

    Inputs (2)

    NameTypeDefaultDescription
    valueFLOAT0.00-2000000000–2000000000
    decimalsINT30–8

    Outputs (1)

    NameTypeDescription
    textSTRING