Nodes/ComfyUI-Data-Analysis/Py String To Int
ComfyUI Node

Py String To Int

Pull an Integer Out of Text — No Float Traps, Just Strictness

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Py String To Int
    • INT
    value

    Your step count, your seed, your row index - they all arrive as text somewhere. Py String To Int turns "42" into the integer 42, which is the difference between a string socket and a numeric socket in a graph.

    It's the sibling of Py String To Float, and the one strictness difference matters: float("3.0") works, but int("3.0") raises. This node is integer parsing, full stop.

    How it works

    It's Python's int(value) on the string. "42" → 42, "-7" → -7, and leading/trailing whitespace is tolerated. It does not round: "3.9" raises rather than becoming 3. It does not accept scientific notation: "1e3" raises. It's a strict integer-literal parser, which is honestly a feature - silent rounding is how bugs are born, and this node refuses to be subtle.

    Inputs and outputs

    • value - the string to parse, single-line.

    Output: an INT, ready for any integer socket - batch sizes, seeds, counts, loop controls.

    Install

    Part of HowToSD/ComfyUI-Data-Analysis. Manager: search "Data analysis" in the Custom Node Manager, install ComfyUI-Data-Analysis, restart, reload the browser tab. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
    mv ComfyUI-Data-Analysis data-analysis   # README: example workflows rely on this folder name
    pip install -r requirements.txt
    

    No models, no GPU.

    Common issues

    The failure mode is a loud ValueError whenever the string isn't a clean integer literal. "3.0" fails, "3.5" fails, " 42 " succeeds. If you have strings like "3.0" that you know represent whole numbers, run them through Py String To Float first and then round - don't expect this node to do it for you. And again, single-line input only; stray newlines will break the parse. If you find yourself converting strings to ints a lot, check whether the data source (like a CSV) can hand you typed values upstream instead.

    CategoryData Analysis

    Inputs (1)

    NameTypeDefaultDescription
    valueSTRING

    Outputs (1)

    NameTypeDescription
    INTINT