Nodes/comfyui-adaptiveprompts/Save Image And Text
ComfyUI Node

Save Image And Text

Save the image and the exact prompt that made it, together

By Alectriciti·Created about a year ago·Updated 2 days ago· 93
Save Image And Text
  • images
    filename_prefixComfyUI
    prompt_data

    The whole point of a dynamic/wildcard prompt is that it resolves to something different every run - which also means you lose track of exactly what tags produced a given image unless you capture that resolved text somewhere. SaveImageAndText is ComfyUI's ordinary image saver with one addition baked in: it writes a matching .txt file next to every saved image, containing whatever text you feed it.

    How it works

    It's a straightforward output node - save the images input the same way a standard Save Image node would, using filename_prefix for naming, and additionally write out prompt_data as a .txt file sharing that same filename. There's no processing here beyond that pairing; the value is entirely in never losing the record of what a randomized prompt actually rolled for a specific image.

    The inputs and outputs that matter

    • images - the images to save, same as any standard image saver.
    • filename_prefix (default "ComfyUI") - supports ComfyUI's usual formatting tokens, like %date:yyyy-MM-dd%, for organizing output by date or run. The .txt file is written with the identical filename, just a different extension.
    • prompt_data - the text content to write into that .txt file. In practice, wire in the resolved prompt output from whatever Prompt Generator (or later processing node) produced your final text.
    • No outputs - this is a terminal node, is_output_node: true, same as any Save Image node.

    How to install it

    Comes bundled with the rest of the Adaptive Prompts pack. Search comfyui-adaptiveprompts in ComfyUI Manager, or install manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Alectriciti/comfyui-adaptiveprompts
    

    Restart ComfyUI. No models, no extra dependencies.

    Common issues & troubleshooting

    The .txt files are empty or full of placeholder text. This is almost always a missed connection, not a bug - it's easy to drop this node in at the end of a graph, wire up images, and forget to actually route your final resolved prompt string into prompt_data. Trace the wire back to your last prompt-processing node (a Prompt Generator, PromptCleanup, whatever produces your truly final text) and confirm it lands here.

    prompt_data doesn't accept multiline the way other text fields in this pack do. The field is defined as single-line in the node's schema, unlike most of the pack's multiline string inputs. If you're feeding it text that legitimately contains newlines - say, a prompt built with newline-separated sections - check the saved .txt output for mangled formatting, and run it through PromptCleanup with cleanup_newlines set to flatten newlines into spaces or commas first if that happens.

    You want this to double as your only image saver. It works fine as one - there's nothing image-specific missing compared to a standard Save Image node - just remember it always expects prompt_data to be meaningful, so on graphs where you don't actually have a dynamic prompt to log, a plain Save Image node is simpler and you won't end up with a stray blank .txt next to every image.

    Categoryimage

    Inputs (3)

    NameTypeDefaultDescription
    imagesIMAGEThe images to save.
    filename_prefixSTRINGComfyUIThe prefix for the files to save. This may include formatting info such as %date:yyyy-MM-dd%. The .txt file will be saved with the same name.
    prompt_dataSTRINGText data to save alongside the image, written into a .txt file.

    Outputs (0)

    No outputs