Danbooru Tag Formatter (Strict)
A prompt tidy-up node that actually formats
- formatted_text
Some prompts look like they were typed by a cat walking on a keyboard: 1girl,long hair,red dress, solo. It still works, mostly, but it's a mess - and for Danbooru-trained models the spacing genuinely matters. "Spaces after commas" is one of the oldest pieces of tag-prompting advice on the anime side of this hobby, because the tokenizer treats red dress, differently from red dress,. The Danbooru Tag Formatter (class DanbooruTagFormatter) is a tiny utility that enforces that rule for you, and it's the more "normalize, don't transform" member of the ComfyUI_Danbooru_Formatter pack.
What it does
Give it any comma-separated string and it returns the same tags, cleaned up: commas get exactly one space after them, stray spaces around tags get stripped, empty entries get dropped, and leading/trailing whitespace disappears. tag_a,tag_b becomes tag_a, tag_b; 1girl, ,long_hair becomes 1girl, long_hair. It does not touch underscores or rename anything - that's the sibling node (Danbooru Tag Auto-Fixer) in the same pack.
The mechanism is deliberately boring: split on commas, strip each tag, throw out the empties, rejoin with ", ". It's one pass, pure standard-library Python, no dependencies, nothing to download. Which is fine - you don't want cleverness in a text-normalizer, you want predictability.
The "Strict" part
The strict_danbooru_check toggle (default off) is where this node becomes a linter instead of a cleaner. Turn it on and it raises an error - the node goes red, the queue halts, the console shows a ValueError with the offending text - in two cases:
- Your input has no commas at all but contains spaces, i.e. it looks like a natural-language sentence rather than a tag list.
- A tag contains an internal space (like
blue hair) instead of an underscore.
There's a thoughtful carve-out: tags starting with < or ( are exempt, so <lora:name:1.0> and weighted (tag:1.2) syntax don't trip the checker. The author's own README advice is to keep strict mode off most of the time - it's a debugging tripwire for when you're automating prompt batches, not something to run day-to-day. Use it once to catch the junk in a pipeline, then switch it back off.
Inputs and outputs
Only what you see: text (multiline string) and strict_danbooru_check (boolean). The one output, formatted_text (a STRING), plugs into any text input - a CLIP Text Encode for the positive or negative conditioning, or a prompt-list node if you're iterating over batches. That's the whole surface area, and that's the point: it sits between your messy source text and the encoder, quietly enforcing the comma-space convention that the KB's own prompting notes call out as a real quality lever.
When you'd actually reach for it
Two situations. First, cleaning WD14 tagger output when you're building anime LoRA training captions - taggers emit comma-separated Danbooru tags, but with inconsistent spacing, and you don't want sloppy formatting baked into a dataset. Second, when you've imported a workflow or a prompt list and want one deterministic pass that makes every line uniform before it hits the model. For the "spaces inside a tag" problem specifically, remember this node only flags that - run it through the pack's Auto-Fixer sibling to actually convert blue hair to blue_eyes.
Installing it
ComfyUI Manager: search "ComfyUI_Danbooru_Formatter" and install. Or clone directly:
cd ComfyUI/custom_nodes
git clone https://github.com/GHOSTLXH/ComfyUI_Danbooru_Formatter
Restart ComfyUI. There's no requirements.txt, no pip step, no model files - one Python file, standard library only, Apache-2.0 licensed. It's about as low-risk a custom node as you can install.
Troubleshooting
The only realistic problem is the red node from strict mode. If it fires on something you consider fine - say, a single tag like blue eyes with no comma - that's the check working as designed, not a bug. Either format your input as comma-separated tags or flip the toggle off. If you wanted the spaces converted rather than rejected, you grabbed the wrong node of the pair; the fixer does that. Used that way, there's basically nothing to go wrong.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| strict_danbooru_check | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| formatted_text | STRING | — |