Danbooru Tag Auto-Fixer (Spaces to _)
The 30-second fix for every 'blue eyes' prompt you ever pasted
- fixed_text
You know the moment. You grab a workflow off the internet, paste an anime prompt into the CLIP Text Encode, hit run, and "blue eyes" just… doesn't behave. The girl has eyes, fine, but not the piercing blue you asked for. Nine times out of ten the culprit is one space: Danbooru-trained models like Illustrious, NoobAI, and Pony learned their vocabulary as underscore-joined tokens (blue_eyes, long_hair), so a spaced tag splits into words the model half-recognizes. The Danbooru Tag Auto-Fixer (class DanbooruTagSnakeCaseFixer) is the node that does this cleanup for you, and it takes about thirty seconds to wire in.
What it actually does
It takes a comma-separated tag list and normalizes it into proper Danbooru form. The interesting part is the space-to-underscore conversion. Feed it blue eyes, red dress, looking at viewer and you get blue_eyes, red_dress, looking_at_viewer - every internal space becomes an underscore, so a multi-word tag like looking at viewer turns into the single token looking_at_viewer. Tags that are already clean (like solo) pass through untouched. The output is a tidy comma-space-joined string ready for the text encoder.
Under the hood it's gloriously simple: split on commas, strip whitespace around each tag, replace internal spaces with underscores, and rejoin with ", ". The one piece of protective logic worth knowing: anything wrapped in angle brackets (<lora:name:1.0>) is left completely alone, so your LoRA triggers survive the trip. Nothing else does - no API calls, no model files, no network. This is pure string surgery, which is exactly what you want from a utility node.
The inputs that matter
There are only two, and you'll mostly touch one:
text- your raw prompt, multiline. Paste anything.reject_natural_language- defaults to on, but the README itself tells you to turn it off. The logic only fires when your input has no commas at all and more than three words, in which case it raises an error rather than turn a sentence intoA_girl_is_standing_in_the_rain. The author admits the natural-language detection is shaky, so unless you're running automated batches and want a tripwire, flip it off.
The single output, fixed_text (a STRING), wires straight into a CLIP Text Encode's text input, or any other node that accepts a prompt string. Since it only converts spaces to underscores and never adds or removes tags, you can also chain it after a formatter node and nothing breaks.
Where it belongs in a workflow
The canonical use case is captioning anime LoRA training data: WD14 taggers famously emit spaced tags like blue eyes instead of blue_eyes, and feeding those into a training run produces sloppy captions. Run the tagger's output through this node and you get the proper underscore vocabulary before the caption ever touches your dataset. It's equally handy for cleaning up prompts copied from model cards or other people's workflows, which are full of hand-typed spaces.
One honest caveat: this is for the CLIP-era, tag-prompting paradigm. Some 2026 models with LLM text encoders (Anima, for example) actually prefer spaces over underscores and happily parse sentences. If you're on one of those, this node is solving a problem you don't have.
Installing it
It's on ComfyUI Manager - search for "ComfyUI_Danbooru_Formatter" and hit install - or clone it the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/GHOSTLXH/ComfyUI_Danbooru_Formatter
Restart ComfyUI and you're done. There's no requirements.txt, no pip install, no model to download; the whole thing is one Python file using only the standard library. That's the rare, pleasant end of the custom-node trust spectrum.
Troubleshooting
The only real failure mode is the red node. If reject_natural_language is on and you paste a comma-free sentence, it throws a ValueError and the console shows a clear message. Turn the toggle off - it's the README's own recommendation - or feed it comma-separated tags. And if a tag comes out looking wrong, remember the angle-bracket carve-out: <lora:x:1.0> survives, everything else gets its spaces squashed. That's the whole job, and it does it without drama.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| reject_natural_language | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| fixed_text | STRING | — |