Nodes/Comfy-Pack/Output Text to File
ComfyUI Node

Output Text to File

Prompts, captions, and JSON straight to disk

By bentoml·Created 2 years ago·Updated 10 months ago· 217
Output Text to File
      text
      filename_prefixcpack_output_
      file_extension.txt

      Output Text to File is the Comfy-Pack node for the quiet half of image generation: the words that go with the pixels. It takes a string, writes it to a text file in your ComfyUI output folder, and marks the result as something the served API can return. Dataset builders, captioners, and anyone who wants a sidecar file with every generation will get more use out of this than its zero clicks in search suggest.

      Comfy-Pack, for context, is BentoML's toolkit for packaging ComfyUI workflows into reproducible .cpack.zip artifacts and serving them as REST APIs. Its output nodes define what a served POST /generate endpoint returns. Image Output handles the tensors; this node handles everything textual - and unlike Image Output, it writes the text as a real file instead of burying it in PNG metadata.

      How it works

      The mechanism is simple and a little underappreciated: it writes the incoming text to your output directory in UTF-8, and it auto-increments the filename so repeated runs never clobber each other. Run the workflow three times and you get prefix_0001.txt, prefix_0002.txt, prefix_0003.txt. That numbering is a small thing until you've blown away a previous generation's captions with a careless overwrite - this node quietly prevents the whole class of bug. It also returns the text in the node's UI output, so even in a local workflow it doubles as a text display node.

      The inputs that matter

      • text - the string to write. It's marked force-input, meaning you're expected to wire it from another node (a prompt builder, a captioner, a JSON stringifier) rather than type it by hand.
      • filename_prefix - default cpack_output_. Give it a real name like caption and outputs become readable.
      • file_extension - optional, default .txt. Swap in .json or .md if that's what your downstream tooling expects.

      No outputs - terminal node.

      Install

      Standard pack install:

      • ComfyUI Manager: search comfy-pack, Install, restart, refresh.
      • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/bentoml/comfy-pack, restart.

      BentoML and comfy-cli come with the pack, so the first install is chunkier than the average node.

      The honest take

      This node is easy to overlook and genuinely handy. If you're building a dataset - generate, caption, write sidecar text - this is the write step, and the auto-numbering means you can leave it running. If you're serving a workflow, a text file output is how the API hands back a string that isn't an image. The one trap is scope: it writes plain text, one file per run, with the same text applied per batch - it doesn't do structured multi-file writing. For that, the pack's Zip Output is the step up: it bundles images with matching text sidecars into a single archive, which is exactly the pairing this node is missing on its own.

      CategoryComfyPack/output

      Inputs (3)

      NameTypeDefaultDescription
      textSTRING
      filename_prefixSTRINGcpack_output_
      file_extensionoptSTRING.txt

      Outputs (0)

      No outputs