Save Checkpoint with Metadata
Save checkpoint .safetensors with custom header JSON, optional prompt override, merge of EXTRA_PNGINFO, and smart/no-counter filename modes. Includes text outputs for…
Nodes (2)
ComfyUI-SaveCheckpointWithMetadata
Save .safetensors files with custom metadata and explicit filename behavior in ComfyUI.
This extension provides two nodes:
Save Checkpoint with Metadata- saves a checkpoint-style.safetensorsfile fromMODEL, with optionalCLIP,VAE, andCLIP_VISIONinputs.Save Diffusion Model with Metadata- saves only aMODEL/ diffusion-model-style.safetensorsfile, withoutCLIP,VAE, orCLIP_VISIONinputs.
Both nodes share the same metadata control and filename behavior:
- Write exactly the header you want via
metadata_json. - Optional
prompt_overrideto replace the hiddenPROMPT. - Merge mode to include hidden
EXTRA_PNGINFO. - Filename modes:
smart_counter: first save uses unsuffixedprefix.safetensorsif free, next saves continue from the next free counter without going backwards.no_counter_overwrite: always write toprefix.safetensorsand overwrite if it exists.
Install
ComfyUI Manager
- Manager -> Install via Git URL -> paste:
https://github.com/a-l-e-x-d-s-9/ComfyUI-SaveCheckpointWithMetadata.git
- Restart ComfyUI.
If Manager shows a security level error, either install manually or add the repo to the Manager catalog. See Troubleshooting below.
Manual
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/a-l-e-x-d-s-9/ComfyUI-SaveCheckpointWithMetadata.git
# optional deps
python3 -m pip install -r ComfyUI-SaveCheckpointWithMetadata/requirements.txt
# optional post-install hook
python3 ComfyUI-SaveCheckpointWithMetadata/install.py || true
Restart ComfyUI.
Node location
- Category:
advanced/model_merging - Display names:
Save Checkpoint with MetadataSave Diffusion Model with Metadata
Which node should I use?
Use Save Checkpoint with Metadata when:
- You want to save a checkpoint-style file.
- You want optional
CLIP,VAE, orCLIP_VISIONsaved into the file. - You want the default prefix to point to
checkpoints/CustomMeta.
Use Save Diffusion Model with Metadata when:
- You want a model-only file similar in purpose to ComfyUI's built-in
ModelSavenode. - You only want to provide a single
MODELinput. - You do not want
CLIP,VAE, orCLIP_VISIONinputs on the node. - You want the default prefix to point to
diffusion_models/CustomMeta.
Quick start - checkpoint save
- Add
Save Checkpoint with Metadata. - Wire your
MODELinto the node. - Optionally wire
CLIP,VAE, and/orCLIP_VISION. - Choose
filename_prefix, for examplecheckpoints/MyModel. - Pick
filename_mode:smart_counterfor automatic unique names.no_counter_overwriteto always writeprefix.safetensors.
- Pick
metadata_mode:replaceto write only yourmetadata_json.merge_minimalto start with prompt plus optionalEXTRA_PNGINFO, then applymetadata_json.
- Fill
metadata_jsonwith a JSON object of header keys. - Optionally set
prompt_overrideto replace the hiddenPROMPTin merge mode. - Queue. Your checkpoint is saved in ComfyUI's output directory under the resolved subfolder.
Quick start - diffusion model save
- Add
Save Diffusion Model with Metadata. - Wire your
MODELinto the node. - Choose
filename_prefix, for examplediffusion_models/MyModel. - Pick
filename_mode:smart_counterfor automatic unique names.no_counter_overwriteto always writeprefix.safetensors.
- Pick
metadata_mode:replaceto write only yourmetadata_json.merge_minimalto start with prompt plus optionalEXTRA_PNGINFO, then applymetadata_json.
- Fill
metadata_jsonwith a JSON object of header keys. - Optionally set
prompt_overrideto replace the hiddenPROMPTin merge mode. - Queue. Your model file is saved in ComfyUI's output directory under the resolved subfolder.
Inputs
Shared inputs
Both nodes have these inputs:
| Input | Type | Description |
|------|------|-------------|
| model | MODEL | The model to serialize into a .safetensors file. |
| filename_prefix | STRING | Subfolder and base name under ComfyUI output directory, for example checkpoints/MyModel or diffusion_models/MyModel. |
| filename_mode | DROPDOWN | smart_counter or no_counter_overwrite. See Filename behavior. |
| metadata_json | STRING (multiline) | JSON object of header keys to write. Values must be strings; non-strings are JSON-encoded for you. Example: {"author":"Alex","training":{"epochs":80}}. |
| metadata_mode | DROPDOWN | replace: write only metadata_json. merge_minimal: base header includes prompt and, optionally, EXTRA_PNGINFO, then your metadata_json overwrites or adds keys. |
| include_extra_pnginfo | BOOLEAN | Used only in merge_minimal. When on, copy keys from hidden EXTRA_PNGINFO into the base header. |
| prompt_override | STRING (multiline) | Optional override for the hidden PROMPT. Ignored in replace. In merge_minimal, becomes the base prompt unless you also set prompt in metadata_json. |
Extra inputs on Save Checkpoint with Metadata
Only Save Checkpoint with Metadata has these optional inputs:
| Input | Type | Description | |------|------|-------------| | clip | CLIP (optional) | Embed CLIP in the checkpoint. | | vae | VAE (optional) | Embed VAE in the checkpoint. | | clip_vision | CLIP_VISION (optional) | Embed CLIP_VISION in the checkpoint. |
Save Diffusion Model with Metadata intentionally does not expose these inputs.
Tip: To see tooltips, enable ComfyUI Settings -> Nodes -> Enable Tooltips.
Outputs
Both nodes output text values so you can inspect what was written:
| Output | Description |
|--------|-------------|
| saved path | Full path to the saved .safetensors file. Named ckpt_path on the checkpoint node and model_path on the diffusion model node. |
| saved_metadata | Final metadata dictionary written to the safetensors header, formatted as JSON. |
| saved_prompt | The final prompt metadata value, if present. |
| saved_extra_pnginfo | The subset of EXTRA_PNGINFO copied into metadata when using merge_minimal. |
Filename behavior
smart_counter
- If
prefix.safetensorsdoes not exist, write there. - Otherwise continue with
prefix_00001_.safetensors,prefix_00002_.safetensors, etc. - The node scans existing files and uses the next free suffix.
no_counter_overwrite
- Always write to
prefix.safetensors. - If the file exists, it is overwritten.
Metadata behavior
replace
The final safetensors header contains only the keys from metadata_json.
prompt_override, hidden PROMPT, and hidden EXTRA_PNGINFO are ignored.
merge_minimal
The node builds a small base metadata dictionary first:
- Adds
promptfromprompt_override, if provided. - Otherwise adds
promptfrom hidden ComfyUIPROMPT, if available. - Adds hidden
EXTRA_PNGINFOkeys ifinclude_extra_pnginfois enabled. - Applies
metadata_jsonlast.
Keys in metadata_json win over keys from the base metadata.
Examples
Replace-only header
- metadata_mode:
replace - metadata_json:
{"author":"author","project":"Flux-Kontext","modelspec.architecture":"sdxl"}
Result: header contains exactly those keys.
Merge prompt and extra info, then override
- metadata_mode:
merge_minimal - prompt_override: paste your workflow JSON or plain text
- include_extra_pnginfo: on
- metadata_json:
{"prompt":"OVERRIDE","author":"Alex","training":{"epochs":80}}
Result: the final prompt value is OVERRIDE, because metadata_json is applied last.
Save a model-only file
Use Save Diffusion Model with Metadata with:
- filename_prefix:
diffusion_models/MyModel - metadata_mode:
replace - metadata_json:
{"author":"Alex","model_type":"diffusion_model","modelspec.architecture":"flux"}
Notes
- Safetensors metadata requires
dict[str, str]. Non-string values are JSON-encoded by the node. - These nodes do not follow the stock
--disable-metadataflag. They write the metadata you specify. - Hidden inputs
PROMPTandEXTRA_PNGINFOare provided by ComfyUI runtime. The nodes only read them whenmerge_minimalis selected. Save Diffusion Model with Metadatasaves only theMODELobject and ignores CLIP/VAE/CLIP_VISION by design.- For maximum compatibility, test the output of
Save Diffusion Model with Metadataby loading it through the same ComfyUI loader you normally use for diffusion model files.
Troubleshooting
Manager shows: This action is not allowed with this security level configuration.
- Option A: Manual install by
git cloneintoComfyUI/custom_nodes/. - Option B: Lower Manager
security_leveltomiddleorweakin itsconfig.ini, then restart ComfyUI. - Option C: Submit your repo to the ComfyUI-Manager catalog (
custom-node-list.json) so it can be installed at normal security. Until the PR is merged, users can use Install via Git URL or manual install.
I see prefix_00001_.safetensors even on the first save
In smart_counter, the node prefers prefix.safetensors if it does not exist. If you still get a numbered file, check that a file named prefix.safetensors is not already present in the resolved output folder.
I want modelspec.* keys like the stock node adds
Add them to metadata_json explicitly. Example:
{"modelspec.architecture":"sdxl","modelspec.vision":"clip"}
The diffusion model file does not load where I expected
Save Diffusion Model with Metadata is intended for model-only saves, but exact compatibility can depend on the model type and the loader you use later. Try loading the output with the same ComfyUI model-only loader you normally use. If you need full checkpoint behavior with CLIP/VAE included, use Save Checkpoint with Metadata instead.
License
No.
Credits
Author: alexds9
Inspired by ComfyUI stock saving logic, with explicit metadata and naming control.