Number to String
Numbers as text, without the 0.30000000000000004
- string_value
Every filename, label, and metadata string you build eventually needs a number turned into text. Number to String does that conversion with one thing the built-in string conversion won't give you: control over the decimal places. Want 3.14 instead of 3.141592653589793? Want a whole number without a trailing dot? This is the node. If you've ever saved a file as strength_0.30000000000000004.png, you know exactly why this exists.
It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. No models, no GPU - this is a format string in a box.
How it works
Two required inputs:
value- the number to convert (FLOAT, default 0)decimal_places- how many digits after the decimal point, 0–10 (default 2)
One output: string_value - the number as a clean STRING.
The implementation splits on decimal_places == 0: that case converts via str(int(round(value))), so 3.7 becomes "4" and 3.2 becomes "3" - no decimal point at all. Otherwise it formats with f"{value:.2f}"-style precision, which is what keeps the string clean rather than dumping raw float noise.
Where you'll use it
- Filenames. Build a save name like
final_cfg_{cfg}_seed_{seed}.pngby converting each numeric parameter to text first and feeding them into the pack'sText Joineror a string formatter. - Labels and captions. Feed the string into a text display or
Debug Printfor human-readable output. - Metadata. Any downstream node that writes text - workflows, tags, info panels - wants a string, and this is the disciplined way to get one.
Installing it
One install, whole pack. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:
cd ComfyUI/custom_nodes
git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
Then restart ComfyUI. Requirements are numpy, torch, and opencv-python - all already in a stock ComfyUI install - and there are no model downloads. Watch out in Manager's search: this is DebugPadawan's ComfyUI Essentials, not cubiq's "ComfyUI Essentials," a different pack that's now in maintenance mode.
Gotchas
- Banker's rounding again. The zero-decimal case uses Python's
round(), which rounds half-to-even -2.5becomes"2". If you need.5to always go up, you'll wantNumber Roundplus a different path. - It truncates by format, not by rounding at higher precision - that's the same Python float rounding behavior, so
2.675with two decimals can give"2.67". Standard float weirdness, not a node bug. - The input is FLOAT; if you're converting an INT from a node that only hands out ints, it coerces fine.
- Small pack, quiet community - for a node this mechanical, you won't find much forum chatter, and you won't need it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | FLOAT | 0.00 | — |
| decimal_places | INT | 20–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string_value | STRING | — |