Nodes/arkennemasis Nodes/arkennemasis Text File Save (caption sidecar)
ComfyUI Node

arkennemasis Text File Save (caption sidecar)

The tiny node that makes a LoRA dataset actually trainable

By Hishamahmer·Created 2 months ago·Updated 8 days ago· 9
arkennemasis Text File Save (caption sidecar)
  • images
  • path
text
folder_path
filename
extensiontxt
overwritetrue

Training toolkits pair an image with its caption by exact basename: shot_001.png sits next to shot_001.txt, and the trainer reads the .txt. That pairing is the entire LoRA dataset, and it's astonishingly easy to break - a caption saved under a slightly different filename, or in the wrong folder, and the image silently trains with no caption at all. ArkTextFileSave writes the caption sidecar with the same folder and filename stem your image save uses, atomically, and binds it to the branch that produced the image. It's the smallest node in the pack and one of the most useful.

How it works

Three required inputs: text (the caption), folder_path (the same folder the image save writes to; relative paths resolve inside ComfyUI's output directory), and filename (the same stem as the image, without an extension). It writes <folder_path>/<filename>.<extension>, defaulting extension to txt. Two touches are worth calling out:

  • Atomic writes. The node writes to a .part file, then os.replaces it into place - a crash mid-write never leaves a half caption.
  • overwrite (default on). Flip it off to refuse replacing an existing file, handy when you want a guard against clobbering hand-written captions.

The subtle input is images - optional, but the tooltip is explicit: wire the generated image in. It binds the caption to that branch, so if a gate upstream returns an ExecutionBlocker and the branch is skipped, the caption is skipped too. No orphan .txt describing an image that was never made.

The captioning rule that decides whether your LoRA works

The node's own docstring states the rule that matters more than any mechanism: anything you caption is excluded from what the LoRA learns. Caption the variable parts - pose, expression, wardrobe, background - and never the face, hair colour or eye colour, or those become separable instead of learned. That's also why a VLM description of the finished image is usually the wrong source: a captioner writes exactly the identity features you must not caption. It's the same advice the KB's LoRA-training essay gives, and it's the difference between a LoRA that learns "this person" and one that learns "this person in this outfit."

Install and context

ArkTextFileSave is one of the 61 nodes in the comfyui-arkennemasis pack, under arkennemasis/Utility:

cd ComfyUI/custom_nodes
git clone https://github.com/Hishamahmer/comfyui-arkennemasis
pip install -r comfyui-arkennemasis/requirements.txt   # then restart ComfyUI

Or ComfyUI Manager → Install via Git URL with the repo URL. No models, no key.

Where it shines: the pack's character-dataset workflow drops in one photo and produces 25 captioned training images ready for kohya, ai-toolkit or diffusers - and this node is what writes the .txt side of every pair. Outside that workflow, it's the disciplined version of a habit you should already have: whatever your Save Image node writes, let a matching caption save ride along on the same folder and stem, so your dataset never silently trains half-captioned.

Categoryarkennemasis/Utility

Inputs (6)

NameTypeDefaultDescription
textSTRINGThe caption. Trailing whitespace is stripped.
folder_pathSTRINGSame folder the image save writes to. Relative paths resolve inside ComfyUI's output directory.
filenameSTRINGSame filename stem as the image, WITHOUT an extension.
extensionoptSTRINGtxtSidecar extension, no dot.
imagesoptIMAGEOptional, but wire the generated image in: it binds this caption to that branch, so a skipped branch writes no orphan caption.
overwriteoptBOOLEANtrueOff = refuse to replace an existing file.

Outputs (1)

NameTypeDescription
pathSTRING