ComfyUI Node

IW SaveString

Keep the exact prompt that made the image

By iwanders·Created 2 years ago·Updated 6 months ago· 2
IW SaveString
      filename_prefixComfyUI
      filename_suffix
      string_field
      extensiontxt

      IW SaveString writes any string to a file in ComfyUI's output directory - as plain text or, if you ask nicely, as pretty-printed JSON. It's an output node with no return wires, and its whole job is persistence: whatever text you feed it ends up on disk next to your images.

      Why you'd want a text file at all

      ComfyUI already stuffs the full workflow into your PNG metadata, which covers reproducibility for most people. But there's a real gap: if your prompt was assembled at runtime - a placeholder swapped in by ReplaceString, or text generated by an LLM like this pack's OllamaGenerateString - the final, actual prompt isn't a constant you can eyeball. Saving the exact string that reached the text encoder gives you a sidecar file you can read, grep, diff, and feed back into a future run. That's the honest use case: audit trails for generated content, or keeping batch metadata without decoding a PNG every time.

      The filenames behave just like image saves, because they use the same underlying get_save_image_path logic: your filename_prefix gets a counter appended, so you won't overwrite previous saves. Prefix plus filename_suffix gives you prompt_00001_batch3.txt style names - the suffix is handy for tagging which batch or which variant a file belongs to.

      The json extension is the interesting one

      extension toggles between txt and json. In json mode the string is parsed and re-dumped with indent=4, so it comes out pretty-printed. The obvious pairing: a node like IW JsonPickItem can read a JSON array - save one with StringSave, pick from it later, and you've got a lightweight config store that lives in output/ and survives restarts. The catch: in json mode your string has to be valid JSON, or the node throws. If you're saving free text, keep it on txt.

      Inputs

      • filename_prefix - base name, defaults to ComfyUI.
      • filename_suffix - appended before the extension.
      • string_field - what gets written, multiline, wired-input enabled.
      • extension - txt or json.

      It's an output node: no return types, nothing to wire onward.

      Installing

      cd ComfyUI/custom_nodes
      git clone https://github.com/iwanders/ComfyUI_nodes
      

      Restart ComfyUI, or install via ComfyUI Manager (search iwanders). No dependencies beyond the standard library. If you've ever spent twenty minutes trying to remember which prompt produced that one good image, this node is the two-second fix.

      Categoryiw

      Inputs (4)

      NameTypeDefaultDescription
      filename_prefixSTRINGComfyUI
      filename_suffixSTRING
      string_fieldSTRING
      extensionCOMBOtxt2 options: txt, json

      Outputs (0)

      No outputs