Nodes/comfyui_LLM_party/String to Integer
ComfyUI Node

String to Integer

The small node that bridges LLM text and ComfyUI numbers

By heshengtao·Created 2 years ago·Updated 10 days ago· 2,328
String to Integer
    • int
    text

    Here's a problem that only shows up once you start letting an LLM control part of a ComfyUI graph: everything an LLM produces is text, even when what it means is a number. Ask a model to pick a batch size, a seed, a step count, or any other integer-typed parameter, and what actually comes down the wire is a STRING like "25" - which ComfyUI's own INT-typed inputs will refuse to accept, because as far as the graph is concerned, a string and an integer are different types that don't connect. String to Integer is the one-job node that closes that gap.

    What it does

    There's exactly one required input, text - a STRING - and exactly one output, int - an actual INT. It parses the string and hands back the numeric value, converted into the type ComfyUI's core nodes actually expect. That's the whole node. It's flagged as an output node too, which in practice just means it's treated as a natural endpoint in a chain rather than something that needs to feed further conversion nodes to be useful.

    Simple as it is, this is a genuinely load-bearing piece of plumbing for agent-style workflows in this pack. If you're prompting an LLM to decide "how many steps should this image use" or "what seed should I run this at" as part of a larger automated pipeline, the model's answer lands in your graph as text no matter what - this node is what lets that decision actually reach a KSampler or any other core node with an INT input.

    Where it fits

    Picture a workflow where an LLM node reasons about a request and outputs a number as part of its response - maybe as plain text, maybe extracted from a JSON blob via this pack's JSON Repair node first. That number is still a string at that point. Wire it through String to Integer, and now it can plug straight into whatever core ComfyUI node needs an actual integer. It's a small connector, but it's the kind of node you don't think about until you need it, and then you need it constantly.

    Installing it

    It's part of the full pack, not a separate download:

    • ComfyUI Manager: search "comfyui_LLM_party", install, restart ComfyUI.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/heshengtao/comfyui_LLM_party, then pip install -r requirements.txt inside your ComfyUI Python environment, restart.

    Nothing about this specific node needs the pack's heavier dependencies (llama-cpp-python, transformers) - it's pure text parsing - but they'll install anyway as part of the shared requirements.txt unless you're on the leaner only_api branch or have fast_installed = True set in config.ini.

    Common issues

    The obvious failure mode is feeding it text that isn't actually a clean number. LLMs are chatty by default - asked for a number, they'll often hand back "The answer is 25" or "25 steps" instead of a bare 25, and depending on how strict the underlying parsing is, that extra text can trip up the conversion. If you're seeing errors here, the fix isn't in this node - it's tightening the prompt upstream so the model returns a bare number, or running the text through a cleanup step (this pack's Replace String node, for stripping known prefixes, is the obvious pairing) before it reaches String to Integer.

    The other thing to watch for is silent truncation: if the model returns a decimal like "25.5" where an integer is expected, how that gets handled (rounded, truncated, or rejected outright) isn't something you should assume - test it once with a known input rather than trusting it blind in a workflow where the exact number matters, like a seed value where "close enough" isn't actually close enough.

    Category大模型派对(llm_party)/转换器(converter)

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    intINT