TextToNumber
Turn a text field into an integer, with an optional random mode
- seed
- INT
TextToNumber bridges the gap between a text field and anything downstream that needs an actual INT. That gap shows up more often than you'd think in ComfyUI: an LLM node hands you back its reply as a plain STRING even if that reply is just the digits "42," a dynamic-prompt or app-mode text box only exposes a text widget rather than a number widget, and plenty of Mixlab's own app-publishing system is built around a small set of input widget types that doesn't include a dedicated free-typed number box. TextToNumber is the node that takes whatever landed in a text field and gives you back a real integer other nodes can actually do math or indexing with.
It works in one of two modes, toggled by random_number (enable/disable). With it disabled - the straightforward path - the node reads text (default "1") and converts it directly to an integer; type or route a numeric string in, get that number out. With random_number enabled, the node ignores text entirely and instead generates a random integer, capped by max_num (2 up to 10,000,000,000, default 10). An optional seed input controls reproducibility for that random draw - set it and you'll get the same "random" number back on repeat runs, useful if you want a workflow that looks randomized but still reproduces exactly for testing.
The single output is INT, ready to wire into anything that takes a plain integer - a seed field, a loop counter, an index into a list, ScenesNode_'s scene selector, whatever your graph needs a number for.
Install is the pack-wide standard:
cd ComfyUI/custom_nodes
git clone https://github.com/shadowcz007/comfyui-mixlab-nodes.git
cd comfyui-mixlab-nodes
install.bat
or via ComfyUI Manager (search "comfyui-mixlab-nodes"), or pip3 install -r requirements.txt in a venv. No model download needed - it's a small text/number conversion utility, nothing more.
The obvious failure mode: feed it a text value that isn't a clean number - stray words, punctuation, an empty string - with random_number left disabled, and there's nothing sensible for the node to convert; expect an error or a fallback to the default rather than a meaningful result. If your text is coming from an upstream node (an LLM reply, a parsed field from somewhere), don't assume it's clean - LLMs in particular love to wrap a number in a sentence ("The answer is 42") rather than emitting the bare digits, and TextToNumber has no parsing logic to extract a number out of surrounding text, only to convert a string that's already just the number. If you're relying on random_number for variety but keep getting the same value across runs, check whether seed is pinned to a fixed number upstream - that's doing exactly what it's supposed to, reproducibility, which looks like "stuck" if you actually wanted fresh randomness on every run. And remember max_num's floor is 2 - you can't use this node to cap a random draw at 0 or 1.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | 1 | — |
| random_number | COMBO | 2 options: enable, disable | |
| max_num | INT | 102–10000000000 | — |
| seedopt | * | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |