ComfyUI Node Runs on cloud

Save Text File

Write a string to disk from ComfyUI

By WASasquatch·Created 3 years ago·Updated 2 days ago· 1,839
Save Text File
      text
      root
      filename_prefixComfyUI
      filename_delimiter_
      filename_number_padding4
      file_extension.txt
      encodingutf-8
      filename_suffix

      Save Text File writes a text string to a file on disk. That's it, and that's plenty - once you're generating text inside a workflow (captions, prompts, logs, metadata), you eventually want to keep it, and ComfyUI's core has no clean way to do that. This node fills the gap.

      Where it earns its keep: you're batch-generating images and want the prompt saved next to each one. Or you ran BLIP to caption a folder of references and want those captions written out. Or you're building a dataset and need the text labels on disk. Anywhere a string needs to leave ComfyUI and become a file, this is the exit door.

      How it works

      You give it the text to save and tell it where to put it - a path, a filename - and it writes the string out. A nice touch specific to WAS: it supports text tokens in filenames, the same token system the Save Image node uses. So you can name files dynamically with things like [time(%Y-%m-%d)] for a datestamp or [hostname], and even define your own tokens with the Text Add Tokens node. That makes it easy to write uniquely-named files across a batch instead of clobbering the same one every run.

      The inputs and outputs that matter

      The essentials are the text you want to write, the path (the folder), and the filename. There's typically a control for the file extension/format and a delimiter option too. It's an output node, so its job is the side effect - the file on disk - rather than passing data onward. Point it at a real, writable folder and feed it the string from whatever produced your text (a caption node, a prompt node, a text concatenate).

      How to install it

      Comes with WAS Node Suite. Install once via ComfyUI Manager (search WAS Node Suite, install, restart) or clone it:

      cd ComfyUI/custom_nodes
      git clone https://github.com/WASasquatch/was-node-suite-comfyui
      pip install -r was-node-suite-comfyui/requirements.txt
      

      then restart. On Windows portable, run the pip step with python_embeded\python.exe -s -m pip install -r ... (or install.bat). No models - it's file I/O.

      Common issues & troubleshooting

      Nothing gets written / permission errors. The path has to exist and be writable by ComfyUI. On Linux or a non-admin Windows account this is a real gotcha - the WAS README specifically calls out needing write permissions on the relevant folders. If no file appears, check the console for a permissions error and point the node at a folder you can actually write to.

      Every run overwrites the same file. If you use a static filename, each run clobbers the last. That's what the token system is for - put a [time] or [time(%Y-%m-%d__%I-%M%p)] token in the filename so each save is unique. This is the single most common "where did my files go" cause: they didn't go anywhere, they overwrote each other.

      The token didn't expand. Tokens go in the filename and follow WAS's token format (built-ins like [time], [hostname], [cuda_device], plus any you add via Text Add Tokens). If a token comes out literal, check the syntax against the README's token list - a malformed token is written as-is rather than expanded.

      Wrong file contents on a batch. If you're saving per-image text across a batch, make sure the text feeding this node actually updates per item - a static upstream string writes the same content to every file regardless of the filename.

      The suite won't import. WAS Node Suite is large and unmaintained since late 2023; the recurring failure is an "Import Failed" after a ComfyUI update, from a dependency version clash (opencv especially). Reinstall the requirements against your ComfyUI Python and restart.

      CategoryWAS Suite/IO

      Inputs (8)

      NameTypeDefaultDescription
      textSTRINGFile contents; STRING, as `a tabby cat`. Written exactly as given. Empty writes an empty file.
      rootCOMBOWhich folder the file lands in: ComfyUI's own 'output' or 'temp', or any folder added under paths.allow_write in config.yaml, listed by its own name. filename_prefix names the part below it, so '[time(%Y-%m-%d)]/notes' files each day's under a dated folder.
      filename_prefixSTRINGComfyUIThe name part of each file, before the number. Tokens are expanded here too, so a date or a custom token can go in the name rather than the folder.
      filename_delimiterSTRING_What sits between the name and the number: 'ComfyUI_0001.txt' with the default, 'ComfyUI0001.txt' if cleared.
      filename_number_paddingINT40–9How many digits the number is padded to with leading zeros: 4 gives '_0001', 1 gives '_1'. Set it to 0 to drop the number and the delimiter entirely and write to the same file every run, replacing what was there.
      file_extensionoptSTRING.txtEnding of the file name, leading dot included: '.txt', '.json', '.csv'. It only names the file; the text is written exactly as it arrives either way.
      encodingoptSTRINGutf-8Character encoding the file is written in. 'utf-8' handles every language and is what almost everything reads; change it only for a program that insists on something else, such as 'latin-1'.
      filename_suffixoptSTRINGExtra text placed after the number and before the extension, so a suffix of '_caption' gives 'ComfyUI_0001_caption.txt'. Empty by default.

      Outputs (0)

      No outputs