Clean Caption (LoRA)
Scrub VLM fluff out of your training captions (and don't forget the trigger word)
- cleaned_text
If you've ever stared at a folder full of auto-generated captions and realized every one starts with "The image is a digital illustration of...", this node is aimed squarely at you. Clean Caption (LoRA) is a single string-in/string-out utility that does the tedious first pass of dataset cleanup for you: it strips the meta-fluff that vision-language captioners like Florence-2, CogVLM, and JoyTag habitually add, drops the "vibes" sentences nobody trains on, and prepends your trigger word to every caption so your whole dataset reads consistently.
Captioning is the most impactful knob in LoRA training - the knowledge base is blunt about it: describe what you want to stay adjustable, leave what should be fixed undescribed, and keep your trigger word identical across the set. For LLM-encoder models (Flux, Qwen-Image, Z-Image) you want clean natural language, and that comes out of VLM captioners, which are verbose by design. This node normalizes that output in the graph, before you save the .txt files next to your images. If you're on the tagged-anime lineage (Illustrious/Pony with a WD14 tagger), stop reading - this is a natural-language tool, not a tag renamer.
How it works
Read the source and it's refreshingly honest: a handful of hardcoded lists and regexes, no dependencies, no API calls. It runs four passes in order:
- Prefix strip - checks ~8 common VLM openers ("The image is a digital illustration of", "The image shows", ...), sorted longest-first, and removes the first match.
- Sentence filter - splits on sentence boundaries and discards whole sentences containing "bad keywords" like "overall style", "overall mood", "cartoon-like", "serene feel".
- Phrase scrub - inside surviving sentences, deletes noise phrases ("vector art", "in the image", "to the scene").
- Format + trigger - collapses whitespace, fixes punctuation spacing, capitalizes, and prepends your trigger word if it isn't already at the start.
The README's example is faithful to the code: "The image is a digital illustration of a futuristic cyborg... The overall atmosphere is dark and moody. In the image, the cyborg is holding a glowing sword." becomes cyb0rg, A futuristic cyborg standing in neon rain. The cyborg is holding a glowing sword.
The inputs that matter
Only three, and only two you'll actually touch:
- text - the raw caption, usually wired straight from a Florence-2/JoyCaption node or a text-file reader. Multiline, so paste away.
- trigger_word - the token you're training. Default is
cayesvgrt, which is clearly the author's personal placeholder. Change it. This is the one real footgun: forget it and every single caption in your dataset silently gets "cayesvgrt," stamped on the front, and you'll be re-captioning at 2am. - enabled - a bypass switch. Flip it off and the node passes text through untouched, handy for A/B-ing cleaned vs. raw captions.
The single output, cleaned_text, is a STRING that wires into whatever node saves your caption files - or back into a text node if you want to eyeball it first. That last part is worth doing.
Installing it
Zero friction, which is rare in the custom-node world. ComfyUI Manager → search "ComfyUI-Caption-Cleaner" → install → restart. Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/cristian1980/ComfyUI-Caption-Cleaner.git
# restart ComfyUI
No requirements.txt, no model downloads, no Python deps - it's pure stdlib, so the dependency hell the ecosystem is famous for doesn't apply here. Find it under LoRA/Text → Clean Caption (LoRA).
Where people get burned
- The whole-dataset paste. Feed it one caption at a time, not a 500-line
.txt. The sentence splitter only breaks on.!?, so a multi-caption paste gets fused into one blob with a single trigger word on the front. - Over-aggressive sentence drops. "image is", "scene is", and "illustration of" are on the kill list, so a legitimate content sentence like "The image is a portrait from the waist up" gets deleted outright, not cleaned. Preview the output before you bake a dataset.
- It's English-only and hardcoded. The keyword lists are baked into the source. If your captioner's phrasing doesn't match the expected patterns, the node does surprisingly little - and there's no config UI to extend it, you'd edit the code.
It's a small, opinionated tool that does one job well for exactly the Florence-2/CogVLM-style caption flow. Set your trigger word, wire captions through it one at a time, and eyeball the first few outputs. Then go train.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| trigger_word | STRING | cayesvgrt | — |
| enabledopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| cleaned_text | STRING | — |