Get Diffusion Model Metadata & Keys
Get Diffusion Model Metadata & Keys — open the hood on a .safetensors file
- metadata
- keys
Sometimes you don't want a preview image, you want the truth. ModelMetaKeys skips the model-page presentation entirely and gives you the raw contents of a diffusion model file: its metadata header, and the full list of every tensor key inside it. This is the node you reach for when you're debugging, not browsing - figuring out whether a mystery .safetensors file is actually a full UNet or something partial, what naming convention its layers use, or what a trainer stashed in the metadata block when they made it.
That last part matters more than it sounds. A .safetensors file is just an 8-byte header length, a JSON header describing every tensor's name/dtype/shape, and then the raw tensor bytes - nothing executable, which is the whole point of the format. Buried in that JSON header is an optional, free-form __metadata__ field, and that's where trainers commonly stash things like LoRA rank or training settings as string key-value pairs. There's no fixed schema for it - it's a convention, not a spec - so the only reliable way to see what's actually in there is to read the header directly. That's what this node does.
How it works. It loads the model file and reads two things out of it: the metadata block, and the list of tensor key names (the layer names, essentially - model.diffusion_model.input_blocks.0.0.weight and so on, depending on the architecture). No network calls, no CivitAI lookups - this is entirely local and entirely about the file's own contents.
Inputs. Just diffusionmodel_name, a dropdown of the diffusion models in your local folder. Nothing else to configure.
Outputs. metadata (STRING) - the raw metadata block, or whatever's in it (which for a lot of files is nothing at all; not every checkpoint carries training metadata). keys (STRING) - the full list of tensor key names in the file. Neither of these is meant to be looked at as-is in the node graph; wire them into a Show Text or Save Text node if you actually want to read them, since they can run to hundreds of lines for a full model.
Where you'd actually use this. Three cases come up in practice. First, sanity-checking a file before you commit to anything with it - is this really the full checkpoint I think it is, or did I accidentally download a partial/pruned version with keys missing. Second, working out layer names before using CheckpointRenameKeys on the same file, since you need to know the exact key strings you're matching against before you can rename them. Third, just reading whatever training metadata got left behind, when a model's own page doesn't say much.
Installing it. Through ComfyUI Manager, searching "Model Utility Toolkit," or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-ModelUtils
then restart ComfyUI. Nothing to download separately - this only reads files you already have.
Troubleshooting. An empty metadata output isn't a bug, it's the honest answer for a lot of models: the __metadata__ block is optional, and plenty of checkpoints, especially ones re-saved or pruned by a third party, simply don't carry any. keys should never come back empty for a valid model file - if it does, you're probably pointing this at something that isn't actually a diffusion model in the format this node expects (a LoRA, an embedding, a corrupted download). Worth running before you feed a suspicious file into anything downstream that assumes a specific key layout.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| diffusionmodel_name | COMBO | 0 options: |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| metadata | STRING | — |
| keys | STRING | — |