Nodes/comfyui-note/Escape Brackets Node
ComfyUI Node

Escape Brackets Node

Your parentheses keep getting eaten — this tiny node puts them back

By wrt122311·Created 4 months ago·Updated 4 months ago· 0
Escape Brackets Node
    • STRING
    text

    Ever pasted a prompt with literal parentheses in it - a song title, a style_(character) tag, a caption - and the output was completely wrong? That's CLIP prompt weighting eating them. On any CLIP-based model (SD 1.5, SDXL, Illustrious, Pony, NoobAI), (word) means "boost this by 10%" and (word:1.3) means "boost it 30%". There's no way to type a plain ( and have it stay a plain (. Unless you escape it. Escape Brackets Node does exactly that, and nothing else - which is the whole point.

    What it actually does

    The entire node is two lines of Python: text.replace("(", "\\(").replace(")", "\\)"). Every ( becomes \( and every ) becomes \). That's it. No model files, no API, no hidden dependencies - the pack is a single __init__.py with one class.

    Why does that work? ComfyUI's own SD1/SDXL tokenizer has a step called escape_important() in comfy/sd1_clip.py that swaps \( and \) for sentinel characters before the attention-weight parser runs, then puts the literal parens back afterward. So an escaped paren sails past the weight parser and lands in your prompt as a plain character. This is the same backslash trick from the A1111 prompt guide - the one people ask about on r/StableDiffusion ("what does the backslash escape do?") whenever they hit a style_\(character\) keyword that keeps getting mangled.

    The inputs and outputs that matter

    There's exactly one of each, and both are named what they are:

    • text (STRING, multiline) - your raw prompt text with literal parens.
    • STRING output - the same text with every paren backslash-escaped.

    Wire the output straight into a CLIP Text Encode node (or anything else that parses prompt syntax). The backslashes are invisible to the final result; the encoder strips them and you get literal parens.

    Installing it

    In ComfyUI Manager, search for comfyui-note and install it, then restart. Or, the manual way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wrt122311/comfyui-note
    

    Restart ComfyUI and you'll find Escape Brackets Node under the text category. There's no requirements.txt and nothing to download - if installing this pack is slow, it's the UI restart, not the node.

    Where people get burned

    • It's a CLIP-era tool. On LLM-encoded models - Flux, Z-Image, Anima, anything Qwen/Mistral/T5-based - prompt weighting doesn't exist, so parens are already just ordinary characters. Run text through this node there and you're not fixing anything, you're adding stray backslashes for the LLM tokenizer to choke on. Use it for SD-family models; skip it everywhere else.
    • It escapes everything. If you feed it (cute:1.2) intending real weighting, you get \(cute:1.2\) - the weight is gone. This node is for text where you want literal parens. Pasted prompts with deliberate weight syntax should not pass through it.
    • It only handles round brackets. [word] is also weight syntax (de-emphasis), and this node leaves square brackets alone. If your text carries those, you'll need to handle them separately.
    • The preview looks alarming. The output shows \( visibly. That's correct. Trust it, don't "clean it up."

    Honestly? If you're typing prompts by hand, you can just type \( yourself and skip this node. Its real home is dynamic text pipelines - wildcard pickers, LLM-generated prompts, text loaded from a file - where you can't hand-edit the string mid-graph. In that spot, a 20-line node that does one job correctly is exactly what you want.

    Categorytext

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING