Nodes/Random Number Button/Random Number Button
ComfyUI Node

Random Number Button

A Physical \"Reroll\" Button for Your ComfyUI Workflow

By HMG-Fiverr·Created about a year ago·Updated about a year ago· 0
Random Number Button
    • random_number

    Random Number Button is one of those nodes that sounds like it shouldn't need to exist, and honestly, for most uses it doesn't. ComfyUI already hands you random integers everywhere - set a KSampler seed to -1 and it rolls a new one every run. What this node adds is the button: a physical widget on the canvas that says Generate, and when you click it, the workflow runs and a fresh random integer between 0 and 1000 pops out. That's the whole product. It's a dice roll you can reach out and tap.

    How it works

    Two halves, and the button half is the one doing the real work. The Python side is four lines - random.randint(0, 1000) with no inputs and a single INT output. The interesting part lives in js/RandomNumberButton.js, which registers a frontend extension. When the node is created, it injects a button widget, and the click handler calls app.queuePrompt(). So the button is really a shortcut to ComfyUI's own queue button, just mounted on the node.

    Here's the thing to understand before you wire it up: because the node has zero inputs, ComfyUI can never cache it. It executes on every queue - whether you hit Queue or click the button, you get a fresh number each run. And clicking the button re-queues your whole prompt, not just this node. Everything downstream re-runs too. If you've got a 20-step sampler at the end of the graph, clicking Generate re-runs it. That's the mechanic, and also the gotcha.

    The one output

    • random_number (INT) - the roll, 0 to 1000 inclusive. The range is hardcoded; there's no min/max widget.

    Wire it anywhere an INT is accepted: a seed, a MathExpression, a batch size, or an integer-driven prompt/checkpoint switcher. One real limitation: the number changes on every run, so you can't "hold" a roll while you tweak other things. If you need a number that sticks until you deliberately reroll, pair this with a Seed-style node that remembers what it last ran.

    Install

    No dependencies, no model files, no requirements.txt - it's Python stdlib plus a tiny JS file. Cleanest install of the week.

    Via ComfyUI Manager: search "Random Number Button" and hit install. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HMG-Fiverr/ComfyUI-RandomNumberButton
    

    Then restart ComfyUI. It shows up under the Agent Assist category, which is an odd home for a utility node but harmless.

    An honest take

    Be clear-eyed about what this is. The README is auto-generated Node Genie scaffolding, the 0–1000 range lives in __init__.py (no way to change it without editing source), and there's essentially zero community presence - no threads, no installs, no one talking about it. You're not missing a scene; there isn't one. It earns its keep as a manual reroll control for people who'd rather tap a button than reach for a widget's dice icon, and it's a genuinely clean example of the "button node" pattern if you're learning how ComfyUI frontend extensions hook into the canvas. For everything else, the built-in randomize on any seed field gets you 90% of the way there for free.

    CategoryAgent Assist

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    random_numberINT