Nodes/ComfyUI-lhyNodes/Save Text as Zip
ComfyUI Node

Save Text as Zip

When Your Output Is a Thousand Text Files, Zip Them First

By lihaoyun6·Created 12 months ago·Updated 13 days ago· 20
Save Text as Zip
      text
      filename_prefixComfyUI

      Most of ComfyUI is about pixels, but a surprising amount of real work is text: generated captions, per-frame prompts, batch metadata, JSON dumps you want to keep alongside images. When that text is a batch - hundreds of lines, one per image or per frame - a pile of loose .txt files in your output folder is a mess. Save Text as Zip (class SaveTextAsZip) does exactly one thing: it takes a text input (or a list of texts), writes each one as a numbered .txt file, and packs them all into a single zip you can grab from your output directory.

      The inputs are as minimal as they come: text (a string - and the node is list-aware, so it handles a batch of strings) and filename_prefix (default ComfyUI). It's an output node with no outputs; the zip shows up in the standard output folder with the usual counter suffix, and the UI reports the generated filename.

      What it's actually for

      The classic pairing is captioning. You run a tagger or an LLM caption pass over a batch of images, and now you have a batch of caption strings that belong with those images. Save Text as Zip turns that into 00000.txt, 00001.txt, … inside one archive - ready to ship alongside (or into) a dataset folder, or to drop into a training pipeline that expects a captions-per-file layout. It's also handy for archiving per-frame prompts from a video workflow, or dumping batch metadata where each item deserves its own file.

      The other way people use it: as a text "export" node that doesn't require a text display. Where a Show Text node is for looking at a value in the UI, this is for getting it off the machine as an actual artifact. Same input, different destination.

      The honest limits

      It's a dumb node on purpose - no formatting, no encoding options, no metadata. Each entry is written as plain text with the default .txt extension and UTF-8, numbered in order. There's no per-file naming beyond the index, so if you need meaningful filenames you'll want to do the renaming downstream. And like its image sibling, it's list-aware: if you feed a multi-item list, make sure the items are actually the strings you want in order, because index position is the only identity they carry.

      Installing it

      Part of lhaoyun6/ComfyUI-lhyNodes. Install via ComfyUI Manager by searching for lhyNodes, or:

      cd ComfyUI/custom_nodes
      git clone https://github.com/lihaoyun6/ComfyUI-lhyNodes.git
      python -m pip install -r ComfyUI-lhyNodes/requirements.txt
      

      Restart ComfyUI after. The pack's shared requirements are ultralytics, opencv-python, numpy, and yarl; this node uses only the Python standard library and downloads nothing.

      It's the smallest node in the pack and proud of it. If your text outputs are already handled, skip it. If you're about to hand a hundred caption files to a training script, this is the two-second way to package them.

      CategorylhyNodes/File

      Inputs (2)

      NameTypeDefaultDescription
      textSTRING
      filename_prefixSTRINGComfyUI

      Outputs (0)

      No outputs