About Unicode Escape Converter
Source files, JSON payloads, HTML and style sheets all have their own way of writing a character that is awkward to type or must stay ASCII. Pick the style you need and this tool escapes your text as you type: \u00e9 for JavaScript, JSON and Java, \u{1F600} for modern JavaScript, é or é for HTML, and \e9 for CSS.
It works the other way too. Paste a string full of escapes and read the text it stands for. Surrogate pairs are joined into the emoji they encode, and an escape that names no valid character is replaced with � and counted rather than silently dropped.
How it works
- Escaping reads the text one code point at a time. By default it escapes only what is not plain printable ASCII, plus the style’s own escape character (\ or &) so that the result reads back exactly.
- The \uXXXX style writes characters beyond U+FFFF as a surrogate pair, as JavaScript, JSON and Java require; the other styles write the code point directly.
- A CSS escape is followed by a space only when the next character would otherwise be read as part of it.
- Unescaping reads only the family you choose (JavaScript, HTML or CSS), so other backslashes and ampersands in your text are left alone.
Questions
Which style should I use for JSON?
The \uXXXX style. JSON accepts only four-digit escapes, so emoji are written as two escapes (a surrogate pair), which every JSON parser joins back together.
Does it decode named entities such as é?
No. It handles numeric references only (é and é). Named entities need a table of more than two thousand names, which the HTML entity tools handle.
Why did part of my text become �?
The escape there names no valid character: a lone surrogate such as \uD83D without its partner, a value above 10FFFF, or zero in HTML and CSS. A note says how many were replaced.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.