Nodes/ComfyUI-LexTools/MD5ImageHashNode
ComfyUI Node

MD5ImageHashNode

The fingerprint that tells you an image is a duplicate

By SOELexicon·Created 3 years ago·Updated about a year ago· 33
MD5ImageHashNode
  • image
  • STRING

MD5ImageHashNode turns an image into a short, unique fingerprint - a 32-character MD5 hash - and hands it back as a string. Two images with the same hash are byte-for-byte identical, which makes this the cheap way to catch exact duplicates in a batch. It's a tiny node with a genuinely useful job: deduplication.

If you've ever generated a thousand variants and then spent an hour deleting the ones that came out identical, you know the pain this solves. The hash is deterministic - same pixels in, same hash out, every time. Log the hashes of everything you generate, and the next run can instantly tell you "I already made this exact image." It also works for verifying that a file hasn't been tampered with or corrupted, though that's a more niche use in a generation context.

How it works

Pure computation, no model. The image tensor is serialized to its raw bytes and run through the standard MD5 algorithm; the resulting digest comes out as a hex string. That's the whole mechanism, which is why the node is instant and has no dependencies beyond what ComfyUI ships.

Inputs and outputs:

  • image - the IMAGE to hash.
  • STRING - the MD5 hash, e.g. d41d8cd98f00b204e9800998ecf8427e.

The important caveat: MD5 catches exact copies only

Here's where people trip. MD5 hashes the pixels as stored in the tensor, so it only matches images that are identical down to the bit. A single pixel different, a one-step resize, a re-encode that shifts a value by one - different hash. It will not catch near-duplicates, resized copies, or recompressed versions of the same image. For perceptual dedup - "these two are basically the same picture" - you want a perceptual hash (pHash/dHash) node from a pack like WAS Node Suite instead. MD5 is the exact-match tool, and it's the right tool exactly when you need exact matches.

That makes it best for the narrow, real case: deduplicating batch outputs where identical frames genuinely repeat (common with fixed seeds or collapsed generations), or deduping a dataset where you want to guarantee no byte-identical duplicates slip through.

Install

Pack install, one time: ComfyUI Manager → search "ComfyUI-LexTools", or

cd ComfyUI/custom_nodes
git clone https://github.com/SOELexicon/ComfyUI-LexTools

then restart ComfyUI. No models, no downloads - the node is pure Python hashing. The main practical friction is the string output: to actually deduplicate across runs you'll need to log the hashes (a text writer, or the pack's own file-based nodes), because ComfyUI doesn't remember strings between sessions. Wire it into your save step and keep a running list.

CategoryLexTools/ImageProcessing/md5hash

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
STRINGSTRING