Number To String
Turn a number into text for filenames and prompts
- number
- result
Most of the time in ComfyUI you want numbers to stay numbers. But every now and then you have a number that needs to become text - to show up in a filename, get pasted into a prompt, or get pushed down a string input that refuses anything else. That's the entire job of Number To String: take a number, hand you the text version of it.
The obvious workflow is saving outputs. A resolution, a seed, a CFG value, an upscale factor - any of these, converted to a string and spliced into a filename template, turns "output.png" into "output_1024_7.5.png" without you retyping anything or hardcoding values that drift as you tweak the graph. It's also the bridge you need before any node that expects a STRING input when all you have is an INT or FLOAT.
How it works
It's Python's str() under the hood, wrapped in a node. You feed it number (int or float, both accepted via the type template), and it returns the string representation as the result STRING output.
The thing to know - because it will surprise you at least once - is that str() is literal. A float like 7.5 becomes "7.5", but a float that happens to be whole, like 7.0, becomes "7.0", not "7". An int 7 becomes "7". If you need "7" out of 7.0, round or floor it first, or feed it an int in the first place. This is one of those places where the "it just converts it" mental model bites: the conversion is faithful, and faithful can mean extra decimals.
The inputs that matter
number- the value to convert. Wire any INT or FLOAT output in, or type it.
Output is result, a STRING, ready for text-concat nodes, filename templates, prompt builders, or anything with a string input.
There's no formatting control here - no decimals argument, no padding, no thousands separators. If you need pretty formatting, do it upstream (round with MathRound, floor with MathFloor, then convert). If you just need the raw text, this is the one.
Install
Part of the ComfyUI-LogicMath pack. Install via ComfyUI Manager (search "ComfyUI-LogicMath", Install, restart) or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-LogicMath
No dependencies, no downloads. If the nodes don't show up after a restart, your ComfyUI is older than the extension API this pack needs - update it.
Common issues
- Filename has a trailing
.0- that'sstr()being faithful, not a bug. Convert an int upstream or round before converting. - Node not in the menu - out-of-date ComfyUI; update first.
The pack also ships StringToNumber for the reverse trip, so if you're moving data both ways across a text boundary, they pair up nicely.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| number | COMFY_MATCHTYPE_V3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |