Number to String
Turn a number into text so it can live in a prompt or a filename
- str
The most boring node in a pack can be the one that unblocks you. ComfyUI's type system is strict about this: a FLOAT widget and a STRING socket are different animals, and when you need a number inside a string - a prompt that mentions a step count, a metadata field, a filename prefix with the current CFG baked in - you can't just drag a number into a text slot.
Number to String is exactly that bridge. It takes a number and hands you its text form. That's the whole job, and it does it with one dynamic input and one output.
How it works
The single input, num_type, is a dynamic combo that decides which flavor of number you're converting:
float- reveals anumfloat input. Your number,0.01step. Converts to text as-is.int- reveals an integernuminput. Converts to text without a decimal point.
The output is str (STRING) - "Output value for str." Nothing clever, no formatting strings, no thousands separators. Float 3.14 becomes "3.14", int 7 becomes "7".
Because the input type is a dynamic combo, the node actually changes shape depending on which mode you pick - choose int and the float widget disappears. That's the one thing that trips people up: the node looks different depending on what's selected, so if you're hunting for a widget that isn't there, check num_type first.
Where it fits
This is glue, and glue earns its place. Common uses:
- Building a prompt string that references a numeric setting ("denoising at 0.35, steps 24") via a Join Text node.
- Composing metadata strings - Sage Utils' whole metadata story is string assembly, and sampler/seed/CFG values are numbers until they're text.
- Dynamic filenames:
cfg_7.0is a much nicer file name than a bare7.0widget value when you're comparing runs.
The pack's own Construct Metadata and Join Text nodes are its natural companions - this is the piece that converts numeric state into something those text-assembly nodes can consume.
Installation
Sage Utils install, same as every node in this 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. Only dependency is dynamicprompts; no model downloads.
The honest take
It's a two-line function wearing a node costume - you could do the same thing with a custom script node or an Anything-to-String in the right pack. But for the price of one pack install, it's right there, typed properly, and it doesn't fight ComfyUI's string system the way a generic "any" output can. If you're already in Sage Utils for the metadata nodes, this is the little converter you'll reach for more than you expect.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| num_type | COMBO | Choose the numeric type to convert to a string. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| str | STRING | Output value for str. |