✨ Prompt Normalizer
((tag)) math, cleaned up
- normalized_prompt
You know that prompt you hand-typed at 1am, the one with ((((masterpiece)))), best quality ,(detailed face:1.2) and a stray (( that never closes? The ✨ Prompt Normalizer is the hangover cure. It takes a raw prompt, fixes the bracket math, cleans the spacing, and hands back a prompt that's consistent enough to drop into a workflow without embarrassment.
This is the lowest-effort, highest-reward node in the ComfyUI-Prompt-Formatter pack, because it has zero setup. No YAML file, no categories, no template. Give it a string, get a string back. It's the one you'll use even if you never touch the categorization nodes.
How it works
Two things happen, and they're both boring in a good way. First, syntax cleanup: it collapses run-together whitespace, normalizes spacing around commas, pipes (|), and brackets, and strips stray opening/closing brackets. Second - the actual feature - weight calculation. In A1111-style syntax, each extra () multiplies a tag's weight by a step (default 1.1), and each [] divides it. The node does that math for you:
((tag))→(tag:1.21)at the default1.1step[tag]→(tag:0.91)- a 1/1.1 de-emphasis, matching what[tag]actually means to the sampler((tag:1.2))→ it parses the explicit weight first, then compounds it:(tag:1.45)
The weight_step input (0.1–2.0) changes the multiplier if you're not using the conventional 1.1. It also normalizes brackets down to the minimum matching pair and drops weights that compute out to ~1.0 (a bare (tag) with nothing to multiply is just tag).
What to wire it into
Output is normalized_prompt, and it slots in anywhere text flows. The classic setup: put it between a wildcard/random generator and your CLIP Text Encode positive so every run gets clean, consistent syntax. It's also a great one-shot for cleaning a big pile of old prompts before you feed them to an analyzer or formatter - the matching in those nodes is more forgiving if brackets are already tidy. You can even leave it dangling in a workflow as a manual paste box: type your garbage, read the cleaned version, copy it out.
Installing
ComfyUI Manager (search "ComfyUI-Prompt-Formatter"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/xLegende/ComfyUI-Prompt-Formatter
Restart ComfyUI. This pack's only dependency is PyYAML, and the normalizer doesn't even need that - it's pure regex, no YAML, no model files. It runs in microseconds.
Common issues
Honestly, it's hard to break. The main thing to know is that it works in A1111's bracket convention - if your workflow uses explicit (tag:weight) everywhere and no bracket stacking, the cleanup is mostly cosmetic. One genuine caveat: on LLM-encoded models like the Flux/Qwen lineage, (tag:1.2) emphasis is largely ignored by the encoder anyway, so a normalizer won't rescue emphasis on those - it'll just make the string tidy. And since it splits on commas outside brackets, a genuinely malformed prompt with unbalanced brackets can merge two tags; if the output looks merged, fix the original instead of fighting it. For the target audience of tag-based models, though, this is the pack's quiet MVP.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| weight_stepopt | FLOAT | 1.100.1–2 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| normalized_prompt | STRING | — |