PVL String To Number
When a string of digits needs to be a real number
- INT
- FLOAT
ComfyUI is picky about types: an INT widget won't accept a STRING wire, full stop. But the world keeps handing you numbers as text - an API response returns "42", a CSV import gives you "512", and this pack's own translation-offset node reports pixel shifts as strings. PVL String To Number is the converter that turns a numeric string into both an INT and a FLOAT you can actually wire into a sampler, a math node, or a dimension input.
It's from pvlprk/comfyui-pvl-api-nodes ("ComfyUI Assistant Node"), and it's a straight clone of ComfyRoll's CR_StringToNumber - which is a compliment, since that node has been the community's go-to for this job for years.
How it works
Give it a text string and it parses it:
- Accepts optional leading
-and a single decimal point, so"-12.5","0.75", and"1024"all work. - Produces a
FLOAT(the parsed value, always) and anINT(the parsed value, rounded by your chosen mode). round_integerhas three modes:round(nearest),round down(floor),round up(ceil).
If the input isn't numeric - letters, empty, malformed - it prints an error to the console and returns nothing, which will make whatever node expects its output fail. That's the main sharp edge.
The rounding quirk nobody reads
The implementation is a clone, quirks and all. For negative numbers, round up truncates toward zero (so -2.7 → -2) and round down floors further (-2.7 → -3). That's the opposite of true mathematical ceil/floor for negatives. Most of the time you're converting positive dims and seeds, so it never bites - but if you're converting a negative offset from the translation-offset node and expect -3 from round up, you'll get -2. Know the quirk or pick round and move on.
Inputs and outputs
text- the string to convert. The node even coerces non-string input to a string, so a number coming in is fine.round_integer- the rounding mode.- Outputs:
INTandFLOAT, both from the same parse.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/pvlprk/comfyui-pvl-api-nodes
restart, or install via ComfyUI Manager (search "ComfyUI Assistant Node"). No models, no dependencies beyond Python's built-ins.
Where it stumbles
- Non-numeric input is a hard failure, not a graceful zero. If you're converting text that might legitimately be empty, gate it upstream or you'll get a broken run and a console message that's easy to miss.
- It parses one number per call. "512,768" isn't two numbers; it's an error. Split first (the pack's PVL Split String exists for exactly this).
- The rounding quirk above is real - read it before you trust
round upon negatives.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | text | — |
| round_integer | COMBO | 3 options: round, round down, round up |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |
| FLOAT | FLOAT | — |