Model Short Hash Extractor
Getting the AutoV2 hash without leaving ComfyUI
- short_hash
Every checkpoint on the internet has a name, and the name is a lie. juggernautXL_v9.safetensors is whatever the uploader typed; two files with that name can be completely different models. The thing that actually identifies a model file is a hash - and the string everyone has agreed to use is the AutoV2: the first ten hex characters of the file's SHA-256. It's what Civitai prints on a model version page, and it's the string A1111 stamps into PNG Info as Model hash:. This node computes it inside your workflow.
Why you'd want it there
Civitai auto-links models and LoRAs to an upload by hash, which is why that ten-character string is the identity key of the whole model-sharing economy and not just trivia. As a node output instead of a terminal command, it becomes data: bake it into filenames, tag it into the metadata string, log it next to your images, or just read it off the canvas to find out which version of a model you actually downloaded - before you post an image and credit the wrong checkpoint.
How it works
The input is a model filename string, and the node resolves the real file through ComfyUI's own folder registry - checkpoints first, then diffusion_models:
model_path = folder_paths.get_full_path("checkpoints", clean_name)
if not model_path or not os.path.exists(model_path):
model_path = folder_paths.get_full_path("diffusion_models", clean_name)
If neither turns up a file, it doesn't raise: it returns the string Error: <name> not found as its output. If it does find the file, it streams the whole thing through SHA-256 in 4 MB chunks and returns hexdigest()[:10] - the AutoV2. Chunked reading keeps memory flat no matter how big the model is.
One source-reading note: the comment above that loop claims it reads "a specific chunk instead of the entire multi-GB file." It doesn't - the loop reads every byte. That's a stale comment, and the shipped behaviour is the correct one, since a partial hash wouldn't match anything on Civitai. It also means the node is I/O bound, not instant.
Wiring it up
The input is model_filename, a STRING declared as a forced input - no text box, so you have to feed it a wire. Drop the node on the canvas, see a blank rectangle, and you'll assume it's broken. Two sane sources: a core Primitive (or String) node you type the filename into, or, staying in the pack, Select Diffusion Model or UNet To CKPT Converter, which exist to carry model filenames around as strings. Include the extension, and use the name the loader shows.
The output is short_hash, a STRING. Convert SaveImage's filename_prefix widget to an input and wire the hash in so every file carries its model identity; feed it into Metadata Append with a key like hash; Merge Two Strings to build name-hash; or just a Show Text node when you're auditing a folder.
Installing it
Same one install as the rest of the pack - Manager, searching the registry title ComfyUI-MDSNodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/MarwanDSAI/comfyui-mdsnodes
Then restart. Nothing to download and no dependencies: requirements.txt is empty and every node in the pack is stdlib Python. The README is stale relative to the code (its node list stops at v1.1.0; this one arrived in v1.6.0), so the file is the documentation. Small single-author pack, built around a Civitai model-testing workflow, no community track record - verify behaviour yourself rather than trusting a write-up, including this one.
Where it bites
Error: ... not found is a perfectly valid string. Nothing downstream will complain; your filename just quietly becomes Error: my_model.safetensors not found and you only notice when you look at the outputs. Also, only the checkpoints and diffusion_models folders are searched. A LoRA, VAE, upscaler or ControlNet filename will not resolve even though you can see the file sitting right there in your models folder.
The first call reads the entire file. On an SSD you probably won't notice. On a spinning disk or a NAS-mounted model library, hashing a 7 GB checkpoint is a genuine wait, and it happens before anything downstream starts. ComfyUI caches node outputs per session, so you pay once per filename per server start - but a restart pays again. Hashing a whole folder is a job for sha256sum, not for a graph.
sha256sum /path/to/model.safetensors | cut -c1-10
The hash not matching Civitai is usually not the node's fault. Any re-save, re-quantisation, metadata edit or merge changes the file's bytes, and a different file is a different hash. People hit this constantly - compare a hash from your machine to the one on the model page, assume something is broken. Check the file with the command above first; other tools in this space have also shipped partial or header-aware hashing that doesn't agree with the plain whole-file hash.
LoRAs are a different scheme entirely. Civitai matches LoRAs on AutoV3 - twelve characters of a SHA-256 computed with the safetensors header skipped - so the file hash and the site hash differ by design. This node produces AutoV2 for checkpoints and diffusion models. That's the whole contract.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model_filename | STRING | The model filename string. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| short_hash | STRING | The 10-character model hash. |