XBHH Prompt Formatter 📝
The prompt janitor that strips bad weights, fixes underscores, and dedupes your tags
- formatted_text
The XBHH Prompt Formatter is a cleanup pass for your prompt text. Paste a messy prompt in - the kind that accumulates bad weight syntax, underscores where spaces should be, duplicate tags, and the odd 5::word:: leftover from some generator - and it returns a deduplicated, normalized string you can feed straight into a text encoder. It's the node equivalent of linting your code before you ship it, and it matters more than it sounds because prompt hygiene is a real quality lever when you're pasting tags from multiple sources.
It ships in the same XBHH kit as the LoRA loaders, and it slots naturally next to them: the Plus loader's triggers output plus a scraped tag list plus a hand-written phrase all get mashed together in one text field, and this node is the thing that makes that mashup presentable.
What it actually does
The format_prompt function runs a defined pipeline over the text:
- Fixes broken weights - strips
number::word::patterns (like5::postcard::), which some tag generators and datasets emit, leaving justpostcard. - Underscores → spaces -
long_hairbecomeslong hair, which is what most encoders want from a civitai-style tag list. - Splits on commas, but not inside brackets - it tracks parenthesis/brace/bracket depth so compound weights like
(cat:1.2), (dog)don't get torn apart at the comma inside the group. - Converts NAI-style weights - the NovelAI brace shorthand
{tag}/[tag]gets rewritten to explicit(tag:weight)notation,{being ~1.05^n and[being its inverse, since ComfyUI's encoders mostly don't understand the brace syntax. - Dedupes - repeated tags collapse to one, keeping the first occurrence and dropping case/whitespace-insensitive duplicates.
- Lowercases - the
to_lowercasetoggle (defaulttrue) makes the whole output lowercase, matching the tag-style conventions most anime/SDXL taggers use.
Output is one formatted_text string: tags joined back with commas.
The inputs
- text - the raw prompt, multiline. The only thing you'll really touch.
- to_lowercase - a two-option dropdown (
true/false). Default true; set false if you're writing natural-language prompts where capitalization matters.
Installing it
It's a node in the XBHH pack:
cd ComfyUI/custom_nodes
git clone https://github.com/xbhh123456/Comfyui-xbhh-main.git
cd Comfyui-xbhh-main
pip install -r requirements.txt
Or ComfyUI Manager → search xbhh-lora → restart. Nothing heavy.
Honest caveats
This is opinionated cleaning, and its opinions are tag-style opinions. If you write prompts as full sentences, the lowercase toggle and comma-splitting will fight you - leave to_lowercase off and keep your own punctuation. The NAI weight conversion targets the NovelAI shorthand specifically; plain ComfyUI weights like (word:1.2) pass through untouched, and the dedup treats (word:1.2) and (word:1.3) as different tags because their text differs. For the common case - you pasted three sources' tags together and want one clean list - it does exactly what it says. Think of it as the formatter at the front of the pipe: dynamic text or a selector produces the raw string, this tidies it, and the CLIP encoder gets the clean version.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| to_lowercase | COMBO | true | 2 options: true, false |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| formatted_text | STRING | — |