Nodes/Comfyui-PixNodes/Universal Unicode Decoder (PixNodes)
ComfyUI Node

Universal Unicode Decoder (PixNodes)

When your text comes back as escaped Unicode, this node decodes it

By pixixai·Created 8 months ago·Updated 6 months ago· 24
Universal Unicode Decoder (PixNodes)
  • input_data
  • text

You pull an API response into ComfyUI and instead of Chinese, emoji, or curly quotes you get a wall of \u4f60\u597d. This is the node that fixes that. Universal Unicode Decoder (PixNodes) takes any string, list, dict, or nested mess, recursively decodes every \uXXXX escape, and hands you clean, readable UTF-8 text on a single STRING output.

Where it earns its keep: this pack also ships LLM API nodes (Kimi, Qwen, DeepSeek, Doubao) plus a big JSON toolbox, and those are exactly the places escaped text piles up. An LLM returns JSON, a JSON node parses it once, and somewhere a \\u4f60 ends up as the literal characters backslash-u-four-f-six-zero instead of "你". It's not only non-Latin scripts either - \n displayed as two characters instead of a newline is the same disease, and this node cures that too.

How it works

The mechanism is more careful than you'd expect for a one-input node. It walks the input recursively (_recursive_decode), so a list, dict, or tuple nested several levels deep gets every string inside it decoded. For each string it tries unicode_escape decoding, and then handles the nasty double-encoded case - where a JSON round-trip turned \uXXXX into literal \\uXXXX text - by running a second pass. If both fail it falls back to a regex that swaps each \uXXXX for its character. Lists and dicts are then re-serialized with json.dumps(..., ensure_ascii=False, indent=2) so brackets and structure stay readable instead of becoming one long unformatted line, and escaped \n, \t, \r, and quotes are restored to their real selves.

That ensure_ascii=False matters, by the way. It's the difference between getting "你好" and getting another wall of escapes - it's the whole reason the node can produce readable Chinese.

The inputs that matter

  • input_data (any type, *) - the only input. It accepts a string, a list, a dict, or anything nested. The wildcard type plus a VALIDATE_INPUTS that always returns True is what lets any wire plug in. A None in gets an empty string out; numbers and non-serializable objects (like tensors) pass through untouched.

  • text (STRING) - the only output. Wire it to a Show Text / preview node, a prompt encoder, a file-save path, anything that wants readable text.

One real-world note from the changelog: version 1.0.8 fixed an "input port type mismatch" bug where the port could refuse certain connections on older builds. If the input won't take your wire, update the pack through Manager before you go hunting for a different node.

Install

It's part of Comfyui-PixNodes, a grab-bag utility pack with no model downloads and a light dependency list (just openai and requests, and you don't need those for this node). Easiest route is ComfyUI Manager:

  • Search PixNodes in the Manager, install, restart.

Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/pixixai/Comfyui-PixNodes
cd Comfyui-PixNodes
pip install -r requirements.txt

Then restart ComfyUI. One trap: the pack README's manual-install section has a copy-paste error and points at a different repo (ComfyUI-AlignLayout). Ignore it - the URL above is the right one.

Troubleshooting

If the output still shows escapes, your data is likely triple-encoded, which is rare - the node only double-decodes. If the output looks right but is ugly unformatted text, that's usually because the input was already a plain string rather than a list/dict, so nothing needed re-serializing. It's a small node, one input and one output, and that's the point: a text-cleaning step you drop between an API call and anything that has to read the result. Ten seconds to wire, and you stop squinting at escape sequences forever.

CategoryPixNodes/text

Inputs (1)

NameTypeDefaultDescription
input_data*输入数据 (String, List, Dict, 或嵌套对象).

Outputs (1)

NameTypeDescription
textSTRING