Nodes/ComfyUI-Scripting-Tools/Generate UUID String
ComfyUI Node

Generate UUID String

A random UUID string when you need one — and why it repeats

By cluny85·Created about a year ago·Updated about a year ago· 1
Generate UUID String
    • uuid_string
    trigger0
    prefix
    suffix

    Sometimes you just need a string that will never collide with anything else. A unique filename for your batch output. A job ID your external script can correlate against. A label that lets you grep one generation out of a thousand. The "Generate UUID String" node exists for exactly that, and it couldn't be simpler: no required inputs, one random v4 UUID out, done.

    It's one of two nodes in the tiny ComfyUI-Scripting-Tools pack from cluny85 (MIT, no dependencies - the repo's requirements.txt says so in so many words). Don't go looking for this pack in the community spotlight; it isn't there. It's a couple of utility nodes a developer published and moved on from, which is honestly all this one needs to be.

    How it works

    Under the hood it calls Python's standard-library uuid.uuid4() - 122 bits of real randomness from your OS, so collisions are a non-problem even if you generate billions of them. There's nothing to tune, no model to load, nothing that touches your GPU. Every execution gives you a fresh v4.

    The trickier bit is ComfyUI itself. The node re-runs only when its inputs change, because ComfyUI caches execution - so you'll hit this pattern immediately:

    1. Queue. You get a UUID.
    2. Queue again, nothing touched. Same UUID.

    That's not the node being broken, that's ComfyUI refusing to waste compute re-running a node whose inputs didn't move. The trigger input exists to defeat the cache: change it (0→1, 1→2, whatever) and the node re-executes and hands you a new UUID. That's the whole point of it, and the source comments say as much.

    The inputs

    Only three, all optional:

    • trigger - an integer you change to force a fresh UUID. Nothing more.
    • prefix / suffix - strings glued onto the front and back of the UUID. This is where filename magic happens.

    The single output is uuid_string - a plain text STRING. Feed it straight into a SaveImage filename_prefix (prefix like run_ gives you run_8f3a2c1e-...png), or into a text node feeding an API call.

    Install

    ComfyUI Manager: search "ComfyUI-Scripting-Tools" and hit install. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cluny85/ComfyUI-Scripting-Tools
    

    Restart ComfyUI. That's the whole install - no models, no pip, no heavy dependencies to babysit. Given the custom-node security climate (any node runs arbitrary code on your machine), it's also trivially auditable: the whole node is one short file you can read before trusting it.

    What it isn't

    If you need a stable ID - the same identifier derived from the same name, every run, everywhere - this isn't your node. Random v4 gives you a new string each execution, which is the opposite of deterministic. For stable IDs you want the pack's sibling, the Enhanced UUID Generator, with its v3/v5 name-based modes. But for "give me a unique label right now," this is the one you'd reach for - and it's about as low-risk as a custom node gets.

    CategoryComfyUI-Scripting-Tools

    Inputs (3)

    NameTypeDefaultDescription
    triggeroptINT00–18446744073709550000
    prefixoptSTRING
    suffixoptSTRING

    Outputs (1)

    NameTypeDescription
    uuid_stringSTRING