ComfyUI Node

RandomInt

The 'randomize me' widget that isn't really a random node

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
RandomInt
    • INT
    value

    The name is a little bit of a lie. UC_RandInt ("RandomInt") doesn't roll dice at generation time the way you'd hope. It's an integer plumbing node whose one trick is that its widget carries ComfyUI's control_after_generate dropdown - the same fixed / increment / decrement / randomize control you know from the KSampler seed. If you set that dropdown to randomize, the value changes after every run. If you leave it on fixed, it's just a boring integer. Either way, what comes out of the INT socket is whatever is sitting in the box.

    Why you'd reach for it

    You want a number in your workflow that changes - but you want to decide how. Wire this into any converted-to-input widget: a LoRA weight you're toggling, a CFG you want to nudge by one each run, a batch count, a denoise value, a text prompt slot that needs to differ run to run. It's the same idea as Core's PrimitiveInt, except Core's primitive is a plain value source and this one adds the control_after_generate behavior on the widget itself, so you get the increment/decrement/randomize ritual without converting anything.

    There's also a sneaky second use. Because a changing value forces everything downstream of it to re-execute, a RandomInt wired into a branch is a cheap "make this always rerun" lever - handy when you've got a node that caches when you'd rather it didn't.

    How it works

    The schema is one input, value (an INT with min/max spanning the full 64-bit range), and one INT output. The execute just passes the value straight through. That's it - the entire logic lives in the widget's control_after_generate=True flag. Under the hood that's the same engine mechanic that drives seed randomize, and the same trap applies: with the dropdown on randomize, the number you see after a run is the one that will be used next. If you've ever lost a good seed to this, you know the drill. The community-standard fix is to flip your global "widget control mode" from After to Before in ComfyUI's settings, once, and this node behaves the way you expect.

    The two inputs that matter

    • value - the integer itself. Set a starting number, then use the dropdown to decide what happens after each run.
    • The control_after_generate dropdown (on the widget, not the socket) - randomize is what makes it behave like a random node; increment/decrement step it; fixed locks it.

    Output is one INT, fan-out-able to as many converted inputs as you need - that's the real reason to use a value node instead of typing five widgets by hand.

    Install

    It ships inside the big ComfyUI-UtilsCollection pack, so you get it with everything else:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
    

    Restart ComfyUI. Or use ComfyUI Manager - Custom Nodes Manager, search "UtilsCollection", install, restart. The pack pulls in opencv-python and typing-extensions on install; neither is anything you need to touch for this node.

    Common issues

    Not much to break here. The usual confusion is expecting real entropy: if you set the value to 5 and leave the control on fixed, you will get 5 forever, which surprises roughly no one. And remember the after-vs-before widget timing if you're chasing a specific number. One genuine gotcha across this pack: it re-registers logic/primitive nodes that some other packs (ComfyUI-LogicMath) also provide, so if a workflow asks you to "replace" a node on load, that's this pack stepping on an old one - accept it and move on.

    Categoryutils/primitive

    Inputs (1)

    NameTypeDefaultDescription
    valueINT-9223372036854776000–9223372036854776000

    Outputs (1)

    NameTypeDescription
    INTINT