ComfyUI Node Runs on cloud

Save Image KJ

Save images with captions and a folder you choose

By kijai·Created 3 years ago·Updated about 20 hours ago· 2,930
Save Image KJ
  • images
  • filename
filename_prefixComfyUI
output_folderoutput
caption_file_extension.txt
caption

Core ComfyUI's Save Image node is fine until you want two things it won't give you: a folder that isn't output/, and a caption text file next to each image. SaveImageKJ does both. That second one is the reason people seek this node out - if you're building a dataset to train a LoRA, you need image/caption pairs (cat_photo.png + cat_photo.txt), and this node writes them together in one step. It's quietly one of the most-used nodes in the pack for exactly that.

What it does differently

Same core job - write your generated images to disk - with two upgrades. You pick the output folder freely, and you can attach a caption that gets saved as a sidecar text file alongside each image. That turns "generate a bunch of images" into "generate a labeled dataset," which is the whole ballgame for training.

The inputs

  • images - what to save.
  • filename_prefix - the base name (default "ComfyUI"). Files get numbered from there.
  • output_folder - where they go. Unlike the stock node, this isn't locked to the ComfyUI output directory, so you can drop images straight into a dataset folder or a project directory.
  • caption (optional) - a string caption. When connected, it gets written to a text file per image. Wire your prompt, a tag string, or the output of a captioning node in here.
  • caption_file_extension (optional) - the sidecar extension, defaulting to .txt. That's the format most trainers (Kohya, ai-toolkit, and friends) expect, so the default is usually right.

The single output is filename as a string - the saved path - which you can log, display, or chain into another step.

The dataset use case

This is where it shines. LoRA training wants a folder of images each paired with a text file describing it. Point output_folder at your training set, feed the caption from whatever's generating your tags, and every run writes a ready-to-train pair. No separate "write text file" node, no manual renaming to keep image and caption names in sync. If you've ever assembled a training set by hand, you know how much of a chore that sync is, and this removes it.

Installing KJNodes

In ComfyUI Manager, search "KJNodes for ComfyUI" in the Custom Nodes Manager, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt (portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart. No downloads.

Watch out for

The custom output_folder is powerful and also the thing that trips people: if the path doesn't exist or ComfyUI doesn't have permission to write there, your images silently don't appear where you expected. Use a path you know is writable, and check there rather than the default output folder when a save seems to "vanish."

Also, the caption file only gets written when you actually connect the caption input. If you were expecting .txt files and got none, that input was probably left empty. And the caption is applied per save - if you're batching many different images that each need a different caption, make sure your caption source varies per image rather than sending one fixed string for the whole batch.

CategoryKJNodes/image

Inputs (5)

NameTypeDefaultDescription
imagesIMAGEThe images to save.
filename_prefixSTRINGComfyUIThe prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes.
output_folderSTRINGoutputThe folder to save the images to.
caption_file_extensionoptSTRING.txtThe extension for the caption file. Limited to plain-text/data formats.
captionoptSTRINGstring to save as .txt file

Outputs (1)

NameTypeDescription
filenameSTRING