Nodes/RF Nodes/To string (NUMBER)
ComfyUI Node

To string (NUMBER)

Stringify any number without caring whether it's an int or a float

By foxtrot-roger·Created 3 years ago·Updated 2 years ago· 2
To string (NUMBER)
    • STRING
    value

    The other ToString nodes in RF Nodes are picky - INT in, INT socket; FLOAT in, FLOAT socket - but a lot of workflow outputs just hand you a NUMBER, the type that could be either. To string (NUMBER) (RF_NumberToString) accepts the union and returns the text. When you don't know or don't care whether a value is an integer or a float, this is the converter that won't complain about the socket type.

    How it works

    str() on whatever arrives. A NUMBER that holds 5 prints "5"; one that holds 5.0 prints "5.0". Note that last detail: the runtime value decides the string, so 5 and 5.0 are distinguishable in the output even though both fit a NUMBER wire. There's no rounding or formatting - convert and stop.

    The inputs that matter

    • value - a NUMBER (accepts INT or FLOAT), forceInput, so it must be wired.

    Output: STRING - the number as text.

    When you'd use it

    Two situations. First, when a node outputs the generic NUMBER type and you want it in a filename or log - this avoids the connection error you'd hit trying to plug a NUMBER into an INT-only socket. Second, when you genuinely don't know the type upstream: build the graph, wire a NUMBER output in, and let this node sort it out. It's the "I'm not thinking about types today" option, which is a legitimate workflow position.

    If you do know the type, the typed variants are a hair more precise - RF_IntToString guarantees integer formatting, RF_FloatToString is explicit about the float. This one just gets the job done.

    Installing RF Nodes

    No dependencies, no models. Via ComfyUI Manager search "RF Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/foxtrot-roger/comfyui-rf-nodes
    

    Restart ComfyUI; it's under RF in the menu.

    Common issues

    • "It's the same as RF_ToString." - Functionally close. The ANY variant also accepts BOOL; this one is number-only. Either works for numbers.
    • "5 prints differently than 5.0." - Correct, and occasionally useful: the string preserves which kind of number arrived.
    CategoryRF

    Inputs (1)

    NameTypeDefaultDescription
    valueNUMBER

    Outputs (1)

    NameTypeDescription
    STRINGSTRING