ComfyUI Node

Save Txt

Save anything as a .txt — prompts, coordinates, debug logs

By 1hew·Created about a year ago·Updated 7 days ago· 33
Save Txt
  • any
  • file_path
filenametxt/ComfyUI
auto_incrementtrue
save_outputtrue
encodeutf-8

ComfyUI saves images all day and forgets everything else. Save Txt is the node that fixes the other half: it writes whatever you feed it to a .txt file on disk and returns the path. Prompts, generated captions, JSON payloads, coordinate strings, a run log - if it can be turned into text, this node can persist it. It's an output node, so it belongs at the end of a branch, and it's one of those unglamorous utilities that you start using once and then can't imagine the workflow without.

How it works

Anything connected to the any input gets stringified: strings pass through, numbers and booleans are converted, and dicts/lists get serialized to pretty-printed JSON. That last bit is the sleeper feature - pipe a structured value in and you get a readable, indented JSON file out, which is great for keeping a record of workflow metadata.

Files land in ComfyUI's output directory (or wherever your absolute path points). The filename field is really a path prefix: the default txt/ComfyUI creates output/txt/ComfyUI.txt. With auto_increment on (default), repeated runs get numbered suffixes instead of overwriting - ComfyUI.txt, ComfyUI_0001.txt, and so on. Turn it off and it overwrites the fixed filename, which is what you want for a scratch log.

encode is a detail that matters more than it looks: utf-8, utf-8-sig (adds a BOM, friendlier to Windows Notepad), or gbk (for Chinese-locale Windows where gbk is the native encoding). save_output off means preview-only - the text shows in the UI but nothing hits the disk.

The inputs that matter

  • any (*) - the value to save.
  • filename (STRING, default txt/ComfyUI) - path prefix under output/.
  • auto_increment (BOOLEAN, default on) - numbered files vs. overwrite.
  • encode - utf-8 / utf-8-sig / gbk.
  • save_output (BOOLEAN, default on) - write to disk or preview only.

One output: file_path (STRING) - absolute path of the file written.

Installing it

ComfyUI Manager → search ComfyUI-1hewNodes → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart ComfyUI. No model downloads. The pack installs heavyweight requirements (rembg, ultralytics, etc.) regardless, and it uses ComfyUI's newer comfy_api.latest API - update ComfyUI if nodes don't show.

Common issues

Two things bite people. First, the filename default is a directory + name, so if you set it to just output you'll get output/output.txt - you're editing a prefix, not a filename. Second, auto_increment defaults on: if you expected a single fixed file and keep seeing numbered copies, that's the setting doing its job. On Windows with Chinese text, garbled output usually means switching encode to gbk or utf-8-sig. And remember it's an output node - if it's not at the end of a chain, nothing downstream gets to use it, and the file_path is your handle for whatever comes after (like a Load Txt on a later run).

Category1hewNodes/io

Inputs (5)

NameTypeDefaultDescription
filenameSTRINGtxt/ComfyUI
auto_incrementBOOLEANtrue为 True 时自动编号;为 False 时固定文件名并覆盖。
save_outputBOOLEANtrue为 True 时写入 txt 文件;为 False 时不保存到磁盘。
encodeCOMBOutf-83 options: utf-8, utf-8-sig, gbk
anyopt*

Outputs (1)

NameTypeDescription
file_pathSTRING