ComfyUI Node

Random Int

A reproducible random number for file names and frame counts

By Conor-Collins·Created 2 years ago·Updated about a year ago· 33
Random Int
    • random_integer_str
    • random_integer
    low1
    high745
    seed0
    use_paddingfalse
    padding_length4

    Sometimes you need a random number that isn't random. That sounds backwards, but it's the whole point of Random Int (class RandomIntNode): a seeded random integer generator that gives you a different value every time you change the seed and the same value every time you don't. It lives in the pack's "File Logistics" category, which tells you what it's really for - naming things.

    Think of a batch render where every output file needs a unique but predictable suffix, or an image sequence where frames are numbered 0001, 0002, 0003. You could hand-wire counters and string math. Or you could drop this node in and let the seed drive the numbering. Because the seed is an input, a workflow that bumps the seed per run produces a new number each time - but the same seed reproduces the exact same number, which is what you want when you're debugging or re-running a batch.

    How it works

    You give it a range and a seed:

    • low (default 1) and high (default 745) - the inclusive bounds. The default high of 745 is a charmingly specific number, but you'll almost always set your own.
    • seed - the thing that makes the output deterministic
    • use_padding - when on, pads the number out to a fixed width (so 4 becomes 0004)
    • padding_length (default 4, up to 20) - how wide the padding goes

    Two outputs, because the two uses want different types:

    • random_integer_str (STRING) - the padded, ready-to-string version for file names
    • random_integer (INT) - the raw number for math, loops, or a KSampler seed

    Where it fits

    The canonical move is feeding random_integer_str into a file name or path builder, so each saved image gets a _0004-style suffix without you hand-typing sequence numbers. The INT output is for anything that wants an actual number - a seed, a batch count, a loop index. The padding option exists specifically so your file names sort correctly: 9.png sorts after 10.png, but 0009.png doesn't. That's the kind of detail that matters when you're processing 500 frames.

    Installing it

    The pack is deprecated - README-marked, unmaintained, and the original repo URL returns 404 on GitHub as of August 2026 (the author's active work lives in ComfyUI-CoCoTools_IO, which doesn't carry this node). Try ComfyUI Manager first, searching ComfyUI-CoCoTools; otherwise:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Conor-Collins/coco_tools
    

    Install requirements (Windows portable, from python_embeded/):

    python.exe -m pip install -r ./ComfyUI/custom_nodes/ComfyUI-CoCoTools/requirements.txt
    

    Restart ComfyUI to pick the nodes up.

    Gotchas

    • The seed default is 0. With a fixed seed you get the same number on every single run - that's the feature, but it surprises people who expected a dice roll. Change the seed for a new value.
    • padding_length does nothing unless use_padding is on. Easy to miss, easy to wonder why your names aren't padding.
    • Because it's abandoned, if you're building something you'll rely on for months, consider a maintained equivalent - but for a simple seeded integer, this one still does exactly what it says.
    CategoryCOCO Tools/File Logistics

    Inputs (5)

    NameTypeDefaultDescription
    lowINT1-2147483648–2147483647
    highINT745-2147483648–2147483647
    seedINT00–18446744073709550000
    use_paddingBOOLEANfalse
    padding_lengthINT41–20

    Outputs (2)

    NameTypeDescription
    random_integer_strSTRING
    random_integerINT