Bracket Escaper
When Your Prompt's Parentheses Are Literal, Not Weighted
- string
In ComfyUI-land, parentheses aren't always punctuation. On CLIP-based models a (word:1.3) is attention weighting, and a bare (word) is shorthand for a boost - the prompt parser eats your brackets before the model ever sees them. Which is a real problem when you want a literal bracket in your text: a character's dialogue, a filename pattern, a LoRA tag you're trying to pass through untouched, or any text destined for a model or tool that uses () for its own syntax.
Bracket Escaper is the fix. It takes a string, escapes everything Python's regex engine would treat as special, and puts a double backslash in front of literal parentheses so they survive the journey as plain characters instead of being interpreted as weights or regex.
How it works
The node is small enough to read in one sitting: it strips surrounding whitespace, runs Python's re.escape over the string, then swaps the regex escapes for the doubled backslash form. The output is the same text with \( and \) (and \[, \], and every other regex metacharacter) rendered as literal characters.
One detail worth knowing: the node declares an IS_CHANGED hook that hashes the input string. That's ComfyUI's way of saying "re-run me when the text changes" - so edits to the string reliably propagate through the graph instead of the node sitting on cached output. Same trick the pack's StringHasher uses.
What you set
Just the one input, string - your prompt or text with the brackets you want protected. The string output is the escaped version, ready to feed into your CLIP encoder, wildcard processor, or text pipeline.
Where people get burned: escaping a bracket after the attention-weight parser already ran does nothing - the escape has to happen before the prompt hits anything that interprets (). So this belongs early in the chain, right at the text source, not downstream after your prompt is already compiled. And it's indiscriminate: it escapes all regex specials, so don't pipe a full weighted prompt like (face:1.2), masterpiece through it expecting only the brackets you care about to change - the whole thing comes out escaped.
Install
It's part of comfyui-rapidfire, with no extra dependencies. Via ComfyUI Manager (search "comfyui-rapidfire") or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Zeks/comfyui-rapidfire
then restart ComfyUI. It's the kind of utility you won't need every day - but the day you're fighting a prompt parser that keeps eating your brackets, it's the right tool and it's already installed.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |