Text Escape
When your JSON is full of backslashes — the escape/unescape tool
- text
Every workflow that passes text between layers eventually hits the escaping problem: your LLM returns JSON and the quotes are all backslashed, or you need to stuff a string into a URL, or a value has special characters that break the next node. TextEscape is the node for exactly that - ten modes that escape or unescape text for JSON, HTML, URLs, Unicode, and slashes.
The mode dropdown covers both directions for five formats. escape_json / unescape_json are the ones you'll actually live in, because they're the fix for the classic "my LLM gave me JSON but it's unusable" mess. JSON escaping turns 她说:"你好" into the version with escaped quotes so it can be nested inside another JSON string; unescaping does the reverse. Mechanically, escape_json uses json.dumps(text, ensure_ascii=False) and strips the surrounding quotes, so your Chinese characters stay readable while quotes and backslashes get escaped. unescape_json is worth one warning: it wraps the text in quotes and tries json.loads, and if that fails it just returns the text unchanged - so malformed input comes back silently unprocessed, not with an error.
The rest are more situational. escape_html / unescape_html (via Python's html module) matter if you're building a web request or an HTML-formatted output - <script> becomes <script>. escape_url / unescape_url URL-encode, and the detail that matters is that escape_url encodes with an empty safe set, so everything non-ASCII gets percent-encoded - 你好世界 becomes %E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C. That's correct for putting Chinese text in a query string, and it's also exactly why unescaping exists. escape_unicode / unescape_unicode flip between literal text and \uXXXX escapes. add_slashes / strip_slashes do the PHP-style backslash escaping (escaping quotes, backslashes, and newlines).
Real uses: cleaning LLM output before it goes into JsonParser (if the model double-escaped its own JSON), building URLs, or making text safe to embed in a string field downstream. The README's AIChatAPI → TextFilterLines → JsonParser pipeline is the natural place - escaping is often the invisible step between "the LLM replied" and "the parser understood."
Install, as with every node in this pack:
cd ComfyUI/custom_nodes
git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
Restart ComfyUI, find it under wwdm-aicd. No heavy dependencies - the node imports stdlib html, urllib, json, and that's it. The README's pip install -r requirements.txt is a non-step because the repo ships no requirements.txt. The author's README and source comments are in Chinese; labels are English.
Honest take: this is a "when you need it, you really need it" node. You won't use it every run, but the day your graph spits out \" garbage and you can't figure out where it came from, this is the two-second fix. The unescape_json silent-failure quirk is the one thing to keep in mind - if it doesn't parse, it hands the input back to you and moves on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| mode | COMBO | escape_json | 10 options: escape_json, unescape_json, escape_html, unescape_html, escape_url, unescape_url, +4 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |