How are \u00xx sequences decoded?
A four-hex-digit \u escape addresses the Basic Multilingual Plane (U+0000 to U+FFFF). The unescaper parses the four hex characters with parseInt(h, 16) and emits the matching code point with String.fromCharCode. So \u00e9 becomes é, \u4e2d becomes 中, and \u00a0 becomes a non-breaking space.
Does it handle \xNN hex byte escapes?
Yes. The legacy \xNN form addresses the first 256 Latin-1 code points. \x41 decodes to A, \x7f to DEL, \xff to ÿ. Anything above \xff requires \u escapes — \xNN cannot represent it.
What is the difference between template literal and single-quoted string escapes?
Template literals (backtick) and quoted strings share the same escape table — \n, \t, \u00xx all work in both. The differences are: template literals additionally escape backtick (\`) and dollar-brace (\${), and they preserve real line breaks. This unescaper handles every escape that appears in either string form, including \` for template literals.
Does it support ES6 \u{...} extended code-point escapes?
Yes. The ES6 \u{1F600} form supports the full Unicode range up to U+10FFFF, including emoji and rare scripts that need a surrogate pair in the legacy four-digit form. The unescaper checks the longer pattern first so \u{1F600} is decoded as a single emoji rather than the literal characters.
Why is the backslash decoded last?
Order matters. If \\\\ were unescaped to \\ first, the next pass might re-interpret it as the escape character of an adjacent sequence. By decoding all named escapes (\n \t \u…), then quotes, then finally collapsing \\\\ to \\, every backslash that survived earlier passes is treated as a literal backslash exactly once.
Will this break valid Unicode characters in my input?
No. Only sequences that begin with a literal backslash are touched. Real emoji, accented letters, CJK characters, and any other Unicode pass through unchanged. Only patterns matching \n, \u00xx, \xNN, etc. are rewritten.
Is the input sent to your servers?
No. The unescaper runs entirely in your browser. Strings containing tokens, secrets, customer data, or proprietary code never leave your device. Open DevTools → Network and click Run to verify no requests are issued.
Is this the same as decodeURIComponent or unescape?
No. decodeURIComponent reverses URL percent-encoding (%20 → space). The legacy global unescape also handles percent-encoding and is deprecated. This tool reverses JavaScript string-literal escapes — the backslash sequences a JS source file uses to embed special characters in a string. Different alphabet, different operation.