Float to String
Format a decimal as clean text
- STRING
You want a float in a filename or a label, and you do not want it to come out as 0.75000001192. JWFloatToString converts a FLOAT to a STRING, and its format string is what keeps the output clean - a controlled number of digits instead of the full floating-point mess.
This matters more than it sounds because floats are imprecise by nature. A value that reads 0.75 in a widget can be 0.7500000119 under the hood, and if you drop that straight into a filename you get an ugly, unsortable name. The format string trims it to something sane. Use this whenever a decimal needs to become text: a save path, an output label, a piece you're concatenating into a larger string.
How it works
It runs your float through a Python format string and outputs the result as text. The default {:.6g} means "up to 6 significant digits, in whichever notation is shorter" - so 0.75 stays "0.75", 3.0 becomes "3", and long tails get cut off cleanly. g is a good default because it drops trailing zeros.
Common alternatives:
{:.2f}- fixed two decimal places (0.75→"0.75",3→"3.00").{:.4f}- four decimals, when you need more precision in the text.{:g}- shortest sensible representation, no fixed digit count.
If you know Python format specs, they behave exactly as expected here.
The inputs and outputs that matter
value(FLOAT) - the number to convert. Default0.format_string(STRING) - the format, default{:.6g}. This is the knob that matters; switch to{:.2f}when you want a fixed number of decimal places.- Output:
STRING- the formatted text.
How to install it
Part of jamesWalker55/comfyui-various, a pack of small utility nodes.
- ComfyUI Manager: search "Various ComfyUI Nodes by Type", install, restart. Node came in red? Install Missing Custom Nodes.
- Manually:
Restart afterward. No models, no dependencies.cd ComfyUI/custom_nodes git clone https://github.com/jamesWalker55/comfyui-various
Find it under the jamesWalker55 category after restart.
Common issues
- The output still has a decimal point I didn't want. If you're putting a float into a filename, a
.in the middle is often fine, but some tools dislike it. Either use a format that avoids it, or convert to an integer first with JWFloatToInteger and format that with JWIntegerToString instead. - Format string errors. The spec has to match a float -
{:.2f}and{:.6g}are valid; an integer spec like{:04d}will throw because the value isn't an int. If you need integer-style padding, convert to int first. - Too many / too few digits. That's the
.6(significant digits) or.2f(decimal places) part of the format. Turn it up or down to taste. - Node is red / missing. The pack isn't installed. Install via Manager or clone the repo, then restart.
It's the mirror of JWStringToFloat: that one reads a number out of text, this one writes a number into text. Together they let you round-trip values through the string side of a graph.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | FLOAT | 0.00-100000000000000000–100000000000000000 | — |
| format_string | STRING | {:.6g} | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |