Nodes/comfy-ovum/_.uniqueId
ComfyUI Node

_.uniqueId

A counter that hands out unique integers

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.uniqueId
  • obj
  • *
prefix

_.uniqueId is the most "JavaScript brain" node in the whole ovum/underscore family: it's a session-wide counter that hands out a fresh integer every time you call it. Underscore.js's docs say it's "useful for temporary DOM ids," which should tell you how well it maps onto Comfy - not a node most people will ever need, but a legitimately neat little tool if you want a guaranteed-unique number for filenames or keys while a workflow is running.

It comes from comfy-ovum, sfinktah's grab-bag pack, and it's an auto-generated wrapper around underscore3, the vendored Python port of Underscore.js. Family warning applies as always: the README describes the underscore nodes as "an absolute disaster to use in production," WIP. For a counter, that's overkill - but be aware this whole family is glue, not infrastructure.

How it works

Underscore's uniqueId keeps a module-level counter that increments with every call. Each invocation returns the next integer (or, with a prefix, a string like contact_1, contact_2…). "Unique within the entire client session" is the guarantee - restart ComfyUI and the counter starts over, so the numbers are unique per session, not unique forever. If you need a collision-proof identifier that survives restarts, use a timestamp or a random string instead; this is strictly a "no two values in this run will match" guarantee.

Inputs and output

  • obj - the primary input (type *, optional). For this method it's a bit vestigial; the generator pattern is auto-generated for every method, and uniqueId mostly ignores the object you pass. You can still pass a _.CHAIN to continue a chain, for whatever that's worth.
  • prefix - STRING widget, default empty. Add a string prefix and the output becomes prefix<counter> (so "shot_"shot_1, shot_2, …). Leave it empty for a bare integer.
  • Output: *.

Install

Manager: search comfy-ovum, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

Restart. No model downloads; the underscore3 port is bundled in the repo.

The honest take

Real talk: this node is a solution looking for a ComfyUI problem. Session-unique integers are occasionally handy for naming a batch of outputs before a save node, and the prefix widget makes that ergonomic. But ComfyUI's save nodes already auto-number files, so you'll rarely need it. It's a fun curiosity to know exists, and if you ever do need a guaranteed-unique counter mid-workflow, here it is - just remember the counter resets with the session.

Categoryovum/underscore

Inputs (2)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.
prefixoptSTRINGprefix (string)

Outputs (1)

NameTypeDescription
**