Nodes/ComfyUI/Save Image-Text (to Folder)
ComfyUI Node Runs on cloud

Save Image-Text (to Folder)

The node that captions your dataset for you

By Comfy-Org·Created 4 years ago·Updated about 20 hours ago· 130,493
Save Image-Text (to Folder)
  • images
    folder_namedataset
    filename_prefiximage
    modeoverwrite
    texts

    Every LoRA trainer in the community will tell you the same thing before they tell you anything else: captions are worth more than any training knob you can turn. And every one of them has also spent an evening manually pairing .png files with .txt files that share a basename, because that's the format every trainer (kohya, ai-toolkit, OneTrainer) expects. Save Image-Text (to Folder) is the built-in node that hands you that exact structure directly from your graph.

    What it is

    It's Save Image (to Folder)'s caption-aware sibling, minus the deprecation. You feed it an images input, optionally a texts input - a list of captions, one per image - plus folder_name (default dataset), filename_prefix (default image), and the mode combo (overwrite / increment). For each image it writes a PNG, then writes a .txt file with the same basename next to it holding that image's caption. image_00000.png gets image_00000.txt. That pairing convention is the entire point: it's exactly what a trainer's folder scanner looks for, so the output of this node is ready to drop into your training run with zero reshuffling.

    The texts input is optional. Leave it disconnected and you just get images; connect a list of strings and every PNG gets its matching caption. The pairing is positional - the first text goes with the first image - so keep the two lists in the same order or you'll train a model that thinks your character's name is the background description.

    Where it fits

    This node is the output end of a training-data pipeline. The usual shape: generate or collect images, run them through a captioning model - JoyCaption or Florence 2 are the community standard for natural-language captions, WD14 if you're in the Danbooru-tag lineage - and wire the results in. The flip side of the same coin is Load Image-Text (from Folder), which reads this exact structure back as two aligned lists. Together they're ComfyUI's native answer to the dataset preparation chore that used to live entirely outside the tool.

    A word on the captioning itself, because the node will happily save garbage if you feed it garbage: describe what you want to remain variable, leave what should be fixed undescribed, and don't caption character work with BLIP - the KB's advice is blunt about that one.

    The inputs that matter

    • folder_name - where the dataset lands, inside output/. The node validates it, so no path escapes.
    • mode - overwrite replaces same-named files; increment appends counters so consecutive queues build up instead of clobbering. If you're assembling a dataset across many runs, you almost always want increment.
    • texts - the captions. The only input that distinguishes this node from its deprecated sibling.

    Getting it and where it goes wrong

    It ships with ComfyUI core, a newer experimental addition in comfy_extras/nodes_dataset.py. No install, no model files. The failure mode to watch for is the positional one: feed it mismatched image/text lists and the files save beautifully - incorrectly. If you're generating captions in another part of the graph, double-check the order before you queue a long training-collection run, because the files are written to disk and a mistake here means a manual re-captioning session at the worst possible time.

    Categoryimage

    Inputs (5)

    NameTypeDefaultDescription
    imagesIMAGEList of images to save.
    folder_nameSTRINGdatasetName of the folder to save images to (inside output directory).
    filename_prefixSTRINGimagePrefix for saved image filenames.
    modeCOMBOoverwriteWhether to overwrite existing files or increment filenames to avoid overwriting.
    textsoptSTRINGList of text captions to save.

    Outputs (0)

    No outputs