String to Int
Turn '42' into 42 (and even '3.14' into 3)
- int_value
Seeds are integers. Steps are integers. Resolutions are integers. And half the time the value you actually want to feed in arrives as a string - from a wildcard, a text node, or a file. String to Int parses text into a proper INT, and it's thoughtful about it: it handles "42", and it also handles "3.14" by converting through float first, so decimal-looking text doesn't just explode.
It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. No models, no GPU - this is int(float(value)) in a box.
How it works
One required input:
value- the STRING to parse (default"0", single-line)
One output: int_value - the parsed number as an INT.
The implementation runs int(float(value)). The float() step is the clever part: it means "3.14" parses fine and becomes 3 (truncated, not rounded), and "42" becomes 42. It also means scientific notation like "1e3" gives 1000. If the string can't be turned into a number at all, the node raises a ValueError - Cannot convert 'abc' to int - so bad input stops loudly instead of corrupting your graph silently.
Where you'll use it
- Seeds and steps from text. A prompt-builder or wildcard hands you a seed as text; convert before feeding the KSampler.
- Config values. Files and switch nodes that output strings containing integers.
- After math that returns floats. It's the natural companion to
Number Round- round to a clean value, then convert to INT for nodes that demand integers.
Installing it
Whole pack, one install. 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 (numpy, torch, opencv-python) are already in stock ComfyUI; no downloads. One naming trap in Manager: this is DebugPadawan's ComfyUI Essentials, not cubiq's "ComfyUI Essentials" - a different, larger pack that's in maintenance mode.
Gotchas
- Truncation, not rounding.
"3.9"becomes3, becauseint(float("3.9"))chops the fraction. If you want4, round first (the pack'sNumber Rounddoes that cleanly). - It raises on garbage. Unlike
String to Boolean, which defaults to True on unknown input, this node will throw on"abc"or"". Fail-fast is good, but validate upstream. - Negative and exponent forms work (
"-7"→-7,"1e3"→1000) but comma decimals ("3,5") do not. - Small pack, quiet community; the behavior is simple enough that the source is the doc.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| value | STRING | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| int_value | INT | — |