String Unescape
When Your Prompt Text Has Literal Backslash-n in It
- unescaped_text
Somewhere between "a JSON file said so" and "the prompt box printed it", escape sequences stop being escape sequences and become plain text. UC_StringUnescape is the node that turns \n back into an actual newline, \" back into a quote, \\ back into a single backslash - that whole family of C-style escapes - so the text you pass downstream is the literal string you meant.
Why you'd reach for it
The classic trigger is loading prompts or metadata that came from a JSON file. JSON stores newlines as \n inside the string, and when a loader hands that text to ComfyUI, you get the literal two characters backslash-n sitting in your prompt - which the model reads as text, and which breaks formatting you wanted. Same story for escaped quotes pasted in from a config, or text that went through a Python repr() and came out the other side wearing its escapes as clothing. Run it through UC_StringUnescape and the escapes are decoded to real characters.
It sits in the pack's text-utility shelf alongside UC_JSONMinifyRepair and UC_StringToNumber - the "text came out of a machine and needs cleaning" trio.
How it works
The implementation is the classic Python trick: it encodes the text as latin-1 with backslashreplace, then decodes with unicode_escape, which is Python's standard "un-escape everything" decoder. If that path fails on odd input, it falls back to a direct codecs.decode(text, 'unicode_escape'), and if that fails it just returns the original text untouched rather than crashing your graph. So \n → newline, \t → tab, \x41 → A, and unicode escapes like \u00e9 → é. Unparseable input degrades gracefully to pass-through.
The input is a single multiline text box; the output is unescaped_text on a STRING socket, ready to wire into a text encode, a Show Text, or whatever consumes clean text.
Installing it
It ships in ComfyUI-UtilsCollection (author: silveroxides):
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart ComfyUI, or grab "ComfyUI-UtilsCollection" from Manager. Dependencies are just opencv-python and typing-extensions - this node uses the standard library only.
Where people get confused
The direction. This node decodes escapes; it does not create them. If you want the opposite - turn real newlines into \n so they survive a JSON round-trip - you're looking for an escaping node, and this pack's UC_JSONMinifyRepair is usually the better tool for JSON-shaped data anyway. Also worth knowing: this node doesn't touch the invisible joiner characters - there's a separate UC_WordJoiner/UC_UnWordJoiner pair in the pack if that's your problem. And if you escape a string that has no escapes, it passes through unchanged, which makes it safe to leave in a chain even when the input is sometimes already clean.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| unescaped_text | STRING | — |