Nodes/Sage Utils/Set Text With Number
ComfyUI Node

Set Text With Number

Text plus a number at the end, with the type switching to match

By arcum42·Created 2 years ago·Updated 28 days ago· 33
Set Text With Number
    • str
    str
    num_type
    prefix
    suffix

    Set Text With Number is Set Text's slightly more opinionated sibling: it builds a string and appends a number to the end. You give it text, it gives you text <number>. The twist is the num_type selector, which decides whether that trailing number is treated as a float or an integer.

    How it works

    Required inputs: str (the main text, multiline) and num_type - a dynamic combo that switches the node's behavior. Pick float and you get a num field (default 0.0, stepped by 0.01); pick int and you get an integer num field instead. Whichever you choose, the node appends that number to the end of your string. The optional prefix and suffix inputs work like the plain Set Text node: prefix goes before the main string, suffix goes after it - but the number always lands at the very end, after the suffix.

    Output is a single str string. So with str = v, num_type = int, num = 2, you get v2. With str = score, float 1.5, you get score1.5.

    Why this beats typing it yourself

    Two reasons. First, it keeps the number as a real number input, so you can wire it from a slider, a batch index, or any int/float-producing node - no string conversion, no manual concatenation. Second, the float/int toggle means you don't get score1.5 when you wanted v2 or vice versa; the field type matches what you're appending. That's the kind of small thing that saves you from a surprisingly common class of bug in metadata or filename strings.

    Installing it

    Part of the Sage Utils pack - ComfyUI Manager (search Sage Utils) or:

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

    Restart ComfyUI. The only pip dependency is dynamicprompts; no models involved.

    Watch out for

    The number is appended with no separator - v + 2 is v2, not v 2. If you want a space or underscore, add it to your suffix or your string. And note the number comes after the suffix, which trips people up: with suffix = x, str = v, num = 2, you get vx2, not v2x. Set your suffix knowing the number always wins the tail end.

    CategorySage Utils/text/helper

    Inputs (4)

    NameTypeDefaultDescription
    strSTRINGText to format with a number at the end.
    num_typeCOMBOChoose whether the appended number should be treated as float or int.
    prefixoptSTRINGText to prepend before the main string.
    suffixoptSTRINGText to append after the main string.

    Outputs (1)

    NameTypeDescription
    strSTRINGOutput value for str_out.