Nodes/ComfyUI Prepack/đź’€Prepack Int Split
ComfyUI Node

đź’€Prepack Int Split

Crack a string like '1024,1024,42' back into real integers

By S4MUEL-404·Created 12 months ago·Updated 10 months ago· 2
đź’€Prepack Int Split
    • int1
    • int2
    • int3
    • int4
    â—„input_string0,0â–ş
    â—„separatorCommaâ–ş

    If đź’€Prepack Int Combine is the glue that turns numbers into a string, this is the solvent. The đź’€Prepack Int Split takes a string like 1024,1024,42 and splits it back into up to four separate integer outputs. Where does that string come from? Usually from somewhere you can't get individual numbers out of - a filename, a saved workflow parameter, a text box somebody typed into, or the output of the Int Combine node when you're round-tripping a value through a string channel.

    It's the node you reach for when a value crosses the "string boundary" in your workflow. ComfyUI treats text and numbers as different universes, and this is the bridge back from text.

    How it works

    You feed it an input_string and pick a separator from the same dropdown as its sibling: Comma, Semicolon, Space, Newline, or Forward Slash. The node splits the string on that character, strips whitespace around each piece, and converts the first four pieces to integers. Missing pieces are padded with 0 rather than erroring - so 1,2 with Comma gives you 1, 2, 0, 0, not a crash.

    The four outputs are named, unsurprisingly, int1, int2, int3, int4. The tooltip is explicit about the padding behavior on the last two: "0 if not present." So if you're parsing strings that sometimes have three values and sometimes four, the third and fourth outputs give you stable zeros instead of undefined behavior.

    Inputs that matter:

    • input_string - the text to parse. Default 0,0, so a bare node is harmless until you wire it.
    • separator - must match whatever separator the string actually uses. This is the #1 mistake: a comma-separated string fed with Space selected will produce one valid int and a pile of zeros (with a console warning).

    The useful pattern is Combine → Split as a pair: combine four numbers into a string, pass it through something string-shaped (a file, a text display, a prompt), then split it back out on the other side. That's how you persist a set of numbers as plain text and recover them losslessly.

    Where people get burned

    The padding is the thing to remember: 0 if not present is not a failure mode, it's the design. If you split a 2-number string and wire int3 into something important, you've silently wired a constant zero. Either check the string always has all four values, or use only the outputs you know are populated.

    Non-numeric strings are another silent trap. "12,abc,34" fails the conversion and the whole node returns 0,0,0,0 with a console message - it doesn't skip the bad value, it zeros everything. And as with the Combine node, negative numbers work fine (they parse from the -), but floats in the string get truncated by int() rather than rounded.

    Installing it

    It's part of the Prepack pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/S4MUEL-404/ComfyUI-Prepack.git
    pip install -r ComfyUI-Prepack/requirements.txt
    

    Or search "Prepack" in ComfyUI Manager. Minimal dependencies (PyTorch, NumPy, Pillow - already present). Restart, look under đź’€Prepack. No models to download.

    If you're getting zeros when you expect numbers, check the separator matches the string's actual separator - and then check for any stray spaces or non-numeric characters in the input, since either one zeroes the whole parse.

    Categoryđź’€Prepack

    Inputs (2)

    NameTypeDefaultDescription
    input_stringSTRING0,0String containing up to four integers separated by the chosen separator.
    separatorCOMBOCommaSeparator used between the integers in the input string.

    Outputs (4)

    NameTypeDescription
    int1INTFirst integer extracted from the input string.
    int2INTSecond integer extracted from the input string.
    int3INTThird integer extracted from the input string (0 if not present).
    int4INTFourth integer extracted from the input string (0 if not present).