String to Float
The boring utility that keeps your graph from screaming at you
- value
Every ComfyUI user eventually hits the wall where one node hands you a number as text and the next node refuses to accept anything that isn't a FLOAT socket. That gap is what StringToFloat exists to bridge. It takes a STRING, parses it as a float, and outputs a FLOAT. That's the entire job. It sounds trivial, and it is - which is exactly why it's useful, because the alternative is hand-editing values or bolting on a heavier utility suite.
It ships in kadirnar/ComfyUI-Transformers, the pack that otherwise wraps Hugging Face pipelines as nodes. This little utility is the pack's outlier: no model, no download, no internet, no heavy dependencies beyond what's already loaded. It's in the "Utility" category, and the source is three lines of real logic:
def convert(self, text):
return (float(text.strip()),)
When you actually reach for it
Think about where strings carrying numbers come from in a workflow. Several nodes in this very pack output JSON as a STRING - a detection result, a classification score, a list of entities. If you want to turn "0.97" sitting inside that JSON into a float you can compare against a threshold, this node is the middleman. It's also how you take a hardcoded text value (like a denoise strength someone typed into a text field) and feed it into a numeric input.
The one real trap: float() is strict. Give it "0.5" and you're golden. Give it "abc", "0.5, 0.7", or anything with stray characters and the node raises an exception that fails your whole run. The default value is "0.0", which is a hint - if you're parsing anything fancier, trim and validate before this node, not after.
Inputs and outputs
text- a single-line STRING, default"0.0".- Output:
value- a FLOAT.
There's nothing else. No range clamp, no fallback, no error handling. Which is fine - utilities should be boring. If you need the reverse direction, the same pack has FloatToString, plus StringToInt and IntToString siblings with identical behavior.
Installing it
With the pack, so the shared install applies:
cd ComfyUI/custom_nodes
git clone https://github.com/kadirnar/ComfyUI-Transformers
cd ComfyUI-Transformers
pip install -r requirements.txt
or search "ComfyUI-Transformers" in ComfyUI Manager. Note the README's cd custom/nodes is a typo. The honest complaint: installing the entire pack - with its torch/transformers/opencv/pandas requirements - just to get a string-to-float converter is a lot of cargo. If that's literally all you want, the ecosystem has dozens of standalone text utility packs (and even core ComfyUI can be coaxed into doing this). The case for this one is that you're already running the pack for the pipeline nodes, so the utility is free.
Troubleshooting
- "could not convert string to float" on your run: your input isn't a clean number. Check for commas, trailing units, or JSON brackets - parse the JSON first, then convert the field.
- It appears under a Transformers category even though it's not a transformer. Cosmetic confusion, but it means you'll find it under Transformers/Utility rather than a generic "utils" menu.
Low drama, tiny footprint, does exactly one thing. Sometimes that's all a workflow needs.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | 0.0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | FLOAT | — |