ComfyUI Node

Save_text_File

Write prompts and captions to disk in ComfyUI

By al-swaiti·Created 2 years ago·Updated 2 months ago· 185
Save_text_File
      filenameinfo
      path
      text

      ComfyUI has a Save Image node baked in, but nothing to save text. That's the gap this fills. It's a terminal node - a dead end in the graph - that takes a string and writes it to a .txt file on disk when the workflow runs. No AI involved despite the "Gemini" pack it ships in; it's a small, honest file-writer.

      Why you'd want it

      Most workflows throw text away. You build up a great enhanced prompt, an LLM writes you a caption, a node spits out some metadata - and the moment the run ends, it's gone unless you copy it out of the UI by hand. Save Text File captures it. The obvious uses:

      • Logging prompts. Wire the enhanced_prompt from a prompt generator into this, and every run leaves a record of exactly what you sent the sampler. Great for "which prompt made that image."
      • Building caption files. Generating a dataset for LoRA training? Route your captions here to write the .txt sidecar files that trainers expect next to each image.
      • Saving anything text-shaped - settings dumps, notes, LLM output you want to keep.

      It's the text counterpart to Save Image, and it's the natural endpoint whenever a branch of your graph produces words you care about.

      How it works and what you set

      Three inputs, all of them plain:

      • text - the string to write. Multiline, usually wired in from an upstream node rather than typed.
      • filename - the name of the file, defaulting to info.
      • path - where to put it. Defaults to empty, which means it writes relative to ComfyUI's own working directory.

      There are no outputs - this is a terminal node (it's flagged as an output node internally), so it fires when you run the graph and there's nothing downstream to connect. Drop it at the end of a branch, run, and the file appears.

      Where people get burned

      "Where did my file go?" This is the number-one confusion, and it's the path input. Leave it blank and the file lands relative to ComfyUI's launch directory, which is often not where you're looking. If you can't find your output, set path to an absolute directory you actually know, and check that ComfyUI has permission to write there.

      Overwrites, not appends. The inputs are just a name and a path - there's no run counter, no auto-increment in the way Save Image gives you _00001. Run the same graph twice with the same filename and the second run stomps the first. If you're logging across runs and want to keep each one, you need the filename to change per run (feed it something dynamic), otherwise you're keeping only the last.

      On a managed or cloud ComfyUI, the file may not come back to you. This is the one that surprises people running on a serverless or hosted setup rather than their own machine. A node that writes to local disk assumes there's a local disk you can reach afterward. On a cloud runner the file gets written inside an ephemeral container that's gone when the job ends, and it isn't part of the outputs the platform hands back - so it can silently vanish. If you need the text off a hosted run, prefer getting it out through the workflow's actual outputs (embed it in image metadata, or return it as a result) rather than trusting a disk write to persist.

      Installing it

      ComfyUI Manager: search ComfyUI-OllamaGemini, install, restart. Or manually:

      cd ComfyUI/custom_nodes
      git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
      pip install -r requirements.txt
      

      then restart. The node needs no API key and no model download - it's pure file I/O. Worth a passing note: custom nodes in ComfyUI run arbitrary Python with full access to your filesystem, and a "write a file wherever you point it" node is a small, benign example of exactly that power. Nothing to fear from this one specifically; just a reminder that the node graph can touch your disk, so keep path pointed somewhere you intend.

      CategoryAI API

      Inputs (3)

      NameTypeDefaultDescription
      filenameSTRINGinfo
      pathSTRING
      textSTRING

      Outputs (0)

      No outputs