ComfyUI Node

XLatentSave

Freeze-frame your generation before it's an image

By Xz3r0-M·Created 8 months ago·Updated about 6 hours ago· 13
XLatentSave
  • latent
  • latent
  • save_path
filename_prefixComfyUI_%Y%-%m%-%d%_%H%-%M%-%S%
subfolderLatents

Every image you've ever generated started as a latent - the compressed tensor that the diffusion model actually works on before the VAE turns it into pixels. XLatentSave lets you grab that tensor mid-pipeline and write it to disk, which is a surprisingly handy thing to be able to do. The use case isn't archiving final art (that's what XImageSave is for); it's checkpointing a generation state you want to resume, share with yourself later, or feed into another stage without going through a lossy decode-encode round trip.

How it works

You give it a latent (LATENT), a filename_prefix, and a subfolder, and it writes a .latent file into your ComfyUI output directory. Same datetime placeholders as the pack's other save nodes - %Y% %m% %d% %H% %M% %S% - so the default template produces ComfyUI_2026-08-16_143052.latent. The subfolder defaults to Latents and, like all the pack's path inputs, is sanitized (no path separators). It saves via safetensors and detects the latent format version, so XLatentLoad can read it back regardless of which recent ComfyUI wrote it.

The node returns two things: the latent passed through unchanged (so it doesn't terminate your chain - you can save and keep sampling in one pass) and save_path (relative to the output dir, useful for logging). Because it's an output node, it marks the end of a path, but the passthrough means it doesn't have to be the only end.

Where it fits

The classic pattern is img2img without pixel loss. Instead of decode → save PNG → reload PNG → encode, you save the latent and reload it later with XLatentLoad, skipping two lossy conversions entirely. The KB makes this point well: the same VAE means the same latent space, and staying in latent space is one lossy cycle you don't pay. The other pattern is debugging - dump the latent at various points in a sampler chain to compare what the noise-to-latent path is actually doing. For that workflow this node is genuinely useful, not a gimmick.

Inputs and outputs

  • latent - the latent to save.
  • filename_prefix - template with datetime placeholders.
  • subfolder - output subfolder (default Latents, no separators).
  • Outputs: latent (passthrough) and save_path.

Installing it

Part of ComfyUI-Xz3r0-Nodes. ComfyUI Manager: search ComfyUI-Xz3r0-Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Xz3r0-M/ComfyUI-Xz3r0-Nodes.git
cd ComfyUI-Xz3r0-Nodes
pip install -r requirements.txt

Restart ComfyUI. No extra dependencies - safetensors ships with ComfyUI.

Gotchas

Same latent-space rule as every latent node: a saved latent only means something in the space of the VAE that encoded it. Save it under Flux, load it into SDXL, and you're feeding the sampler a tensor in a language it doesn't speak. And since latent files are bigger than decoded PNGs and completely opaque to humans, don't use them as your only copy of anything - they're working state, not an archive. Pair XLatentSave with XLatentLoad, keep the model family consistent, and it's a clean workflow; ignore the VAE and you'll chase phantom bugs.

Category♾️ Xz3r0/File-Processing

Inputs (3)

NameTypeDefaultDescription
latentLATENTInput latent tensor to save
filename_prefixSTRINGComfyUI_%Y%-%m%-%d%_%H%-%M%-%S%Filename prefix, supports datetime placeholders: %Y%, %m%, %d%, %H%, %M%, %S%
subfolderSTRINGLatentsSubfolder name (no path separators allowed), supports datetime placeholders: %Y%, %m%, %d%, %H%, %M%, %S%

Outputs (2)

NameTypeDescription
latentLATENTOriginal input latent (passed through)
save_pathSTRINGSaved file path relative to ComfyUI output directory