Batch Save Image and Caption
The node that turns a captioning run into a LoRA-ready dataset
- images
Captioning a batch of images is only half the job. The other half is getting image and caption onto disk as a matching pair - and that's the part people do by hand, badly. Batch Save Image and Caption (class CFICLS_SaveImageCaptionBatch) takes a batch of images plus the captions you've generated for them and writes each out as an image file with a sidecar caption file sitting next to it. That's the exact layout LoRA trainers expect: image.png and image.txt sharing a base name.
Why you'd bother
Export a dataset manually once and you'll know the pain: thirty PNGs, thirty .txt files, and a low-grade fear that somewhere an image and its caption got out of sync. This node kills that whole bug class by construction - image and caption get the same base filename, written in the same pass, so a mismatch is hard to produce and easy to spot.
The typical flow: load a folder of images (the pack's other node does exactly that), run them through a captioner, and export. Which captioner depends on your base model. The community consensus the KB records is WD14 tagger for the Danbooru-tag lineage (Illustrious, Pony, NoobAI) and JoyCaption or Florence 2 for natural-language models like Flux. Either way, the export step is the same.
The inputs
Four inputs, and you'll touch three of them:
- images - the batch of IMAGE tensors to save.
- captions - the text for each image. Feed in the matching batch of caption strings from your captioning node, one per image.
- prefix (default
IMG) - the base filename for each pair.IMGgets youIMG_0001.pngplusIMG_0001.txt, and so on down the batch. - extension (default
.txt) - the caption file's extension. Keep it.txt. Training scripts look for.txtsidecars specifically; change it to something clever and your trainer will silently find no captions at all.
There are no outputs, and that's the point: it's a terminal node. Everything upstream feeds it and the workflow ends here.
Installing it
Same pack as the loader, so same install: ComfyUI Manager → search "Save Images with Captions," or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/TheBill2001/ComfyUI-Save-Image-Caption
Restart and you're done. No models to download, no pip dependencies, no post-install step. The README is one sentence, which is a reliable sign there's nothing else to configure.
Common gotchas
- Where did the files go? There's no folder field on this node - the schema only has images, captions, prefix, and extension. So it writes to a fixed default location, almost certainly ComfyUI's output directory. Run it once and go look there before you assume it's broken.
- Overwrites. Rerun with the same prefix into the same folder and you'll clobber (or renumber over) the previous batch. Give each run its own prefix if you want to keep both.
- Captions must match images in count. It can only pair what you give it. A shorter caption list than image list means some images ship without captions, and a trainer will either skip them or read the wrong file. Line the batch sizes up.
- Keep the
.txt. Already said it, but it's the one that bites people, so it bears repeating - that's the convention every trainer is built around.
The author shipped a thin pack and no documentation, but the shape here is simple and every failure mode is visible from the inputs. If you're building a ComfyUI-based dataset pipeline, this is the least fiddly part of it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| captions | STRING | — | |
| prefixopt | STRING | IMG | — |
| extensionopt | STRING | .txt | — |
Outputs (0)
No outputs