ComfyUI Node

isnumeric

Isnumeric — the gate that keeps bad numbers out of your INT casts

By StableLlama·Created about a year ago·Updated about 15 hours ago· 48
isnumeric
    • BOOLEAN
    string

    You're reading a value from a file, a CSV, an API response, or a URL parameter. You need it as an integer. You shove it into a cast node. It blows up because the string had a stray letter in it. isnumeric is the node you put before that cast so the failure never happens - it answers "is every character in this string numeric?" with a real BOOLEAN you can branch on.

    The classic setup is a guard: check the string with isnumeric, wire the BOOLEAN into a conditional, and route to your cast on True, a default value or an error path on False. That turns a crash into a workflow decision.

    How it works

    This is Python's str.isnumeric(). It returns True when the string is non-empty and every character is numeric. But "numeric" is broader than you'd guess from a 0-9 keypad. It includes characters with the Unicode numeric value property, which means:

    • "123"True
    • "١٢٣" (Arabic-Indic digits) → True
    • "½" (the fraction) → True
    • "Ⅻ" (Roman numeral twelve) → True
    • "1.5"False (the dot isn't numeric)
    • "-5"False (the minus sign isn't numeric)
    • "12_000"False
    • ""False

    That's the honest gotcha in both directions: it accepts Unicode numerals most people don't expect, and it rejects the minus sign and decimal point that make numbers actually useful. It's a digit-character check, not a "can this parse as a number" check.

    Inputs and outputs

    Just one required input, string (default ""), and one BOOLEAN output. Type or wire in the text you're validating. The output goes into a conditional, an if/else, or any comparison that wants to branch on "is this a number".

    Installing it

    This is part of the Basic data handling pack by StableLlama. Install via ComfyUI Manager (search "Basic data handling") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart ComfyUI after. The pack has zero Python dependencies and downloads no model files - which is why it keeps appearing inside shared workflows without requiring a dependency rescue mission. The node lives under Basic/STRING/is.

    Common issues

    The big one: isnumeric being True doesn't mean int() will accept the string. "½".isnumeric() returns True, but int("½") raises an exception - the fraction has a numeric value property without being an integer you can cast. So treat this as a pre-filter, not a guarantee. Pair it with the pack's to INT cast and handle the edges yourself if your data can contain Unicode fractions or superscripts.

    Also remember it has no opinion about sign or decimals. If you're validating something like a CFG value that could be -1.5, isnumeric will reject it on the dot or minus - you want a different check for that, not this node. For plain unsigned integer strings from files and APIs, it's exactly right.

    CategoryBasic/STRING/is

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN