ComfyUI Node

any to hash

Turn any node output into a stable fingerprint

By lokinou·Created 11 months ago·Updated 8 months ago· 2
any to hash
  • anything
  • string

"Hash everything" sounds like a utility you'll never need, until you need it constantly. any to hash takes whatever is connected to it - an image, a prompt string, a latent, a conditioning, a list - and returns a 32-character MD5 hex string that acts as that object's fingerprint. Same input, same hash. Change the image or the prompt, and the hash changes. That one property unlocks the boring-but-powerful tricks this pack is built around: detecting whether something changed between runs, keying a cache, or comparing two outputs to confirm they're actually identical.

It's the natural partner to Cache any - feed this hash into a cache key and you get "same prompt + same image → skip the expensive part," which is the closest ComfyUI gets to an incremental build. You can also drop it at the end of two near-identical workflows and check that they produced the same thing, seed weirdness aside.

How it works

Under the hood it's simple: it serializes the input to bytes and runs MD5 over them. The interesting detail is how it serializes. Plain pickling of a PyTorch tensor is unstable - the same image living in VRAM vs. RAM can produce different bytes, which would make the hash useless. So the node special-cases tensors: it moves them to CPU and converts to raw bytes first, which is why image hashes stay consistent run-to-run. Non-tensor inputs get pickled at the highest protocol and hashed.

Two honest limitations from the README: it raises on a None input (so don't wire it where the value can be empty), and the tensor fix is solid for images but other tensor-heavy types - the README calls out conditionings - can still produce unreliable hashes. Don't use this to prove two conditionings are equal.

Inputs and outputs

Just one of each, which keeps it easy to reason about:

  • anything (required, any type) - whatever you want fingerprinted.
  • string (output, any type) - the MD5 hex digest.

The node is also an output node, and it does a nice UI touch: it writes the hash back into its own widget value, so you can see the fingerprint on the canvas without chasing wires. The output is typed as "any" so it plugs straight into the key input of CacheAny or any string-ish consumer.

Install

It ships in lokinou/comfyui-better-flow, so one install covers this and the rest of the pack. Via ComfyUI Manager, search "comfyui-better-flow", or:

cd ComfyUI/custom_nodes
git clone https://github.com/lokinou/comfyui-better-flow.git

Then restart ComfyUI - a full restart, not just Reload, so the nodes register. There's no pip step and no model download; the pack is pure Python with zero extra dependencies.

When to reach for it

The honest use-case list is short: cache keys, change detection, and equality checks. If you're not doing any of those, you don't need it. But if you've ever rebuilt a 40-node workflow because you weren't sure whether your tweak actually changed the output, one of these on the final image settles it - and that's worth a lot more than the five seconds it takes to add the node.

Categoryworkflow

Inputs (1)

NameTypeDefaultDescription
anything*

Outputs (1)

NameTypeDescription
string*