Unicode Escape / Unescape
Turn any text, accents or emoji into escape sequences for JavaScript, JSON, Java, Python, C, HTML or CSS, or paste escaped text to decode it back to readable characters. Every escape style is detected automatically and the result updates as you type.
Character breakdown
| Char | Code point | UTF-8 bytes | UTF-16 | HTML | Escape | Count |
|---|
How to use the Unicode Escape / Unescape
- Choose a mode: Escape turns text into escape sequences, Unescape turns escape sequences back into text.
- Pick the escape style for your language, for example \uXXXX for JavaScript, JSON and Java or &#x; for HTML.
- Type or paste into the input box. The output updates instantly.
- Select which characters to escape: only non-ASCII (keeps code readable) or all characters.
- Copy or download the result, or press Swap to send it back to the input and reverse the conversion.
- Check the breakdown table to see each character's code point and bytes.
Unicode escape syntax by language
The same character is written differently in each language. This table shows the euro sign € (U+20AC) and the grinning face 😀 (U+1F600), which lies outside the Basic Multilingual Plane:
| Language / format | € (U+20AC) | 😀 (U+1F600) | Notes |
|---|---|---|---|
| JavaScript, JSON, Java, C# | € | 😀 | UTF-16 code units; astral characters need a surrogate pair |
| JavaScript ES6, Swift, Rust, PHP 7+, Ruby | \u{20AC} | \u{1F600} | 1 to 6 hex digits in braces (Swift and Rust: up to 8 / 6) |
| Python, C, C++ | € | \U0001F600 | Python also writes U+0000 to U+00FF as \xHH |
UTF-8 bytes (C, PHP, shell printf, Python bytes) | \xE2\x82\xAC | \xF0\x9F\x98\x80 | One escape per byte of the UTF-8 encoding |
| Perl | \x{20AC} | \x{1F600} | Also \N{U+20AC} |
| HTML / XML | € or € | 😀 or 😀 | Hex or decimal numeric character reference; named € also exists |
| CSS | \20AC | \1F600 | Up to 6 hex digits; a following space ends the escape |
| Unicode notation | U+20AC | U+1F600 | Used in documentation, not in code |
How surrogate pairs are calculated
UTF-16 can store only 65,536 values in one unit, so code points from U+10000 to U+10FFFF are split in two. Subtract 0x10000 from the code point, then:
- High surrogate = 0xD800 + (value ÷ 0x400, rounded down)
- Low surrogate = 0xDC00 + (value mod 0x400)
For 😀: 0x1F600 − 0x10000 = 0xF600. 0xF600 ÷ 0x400 = 0x3D, so the high surrogate is 0xD83D; 0xF600 mod 0x400 = 0x200, so the low surrogate is 0xDE00. That gives 😀. A lone half of a pair is invalid text, which is why the tool warns about unpaired surrogates.
Tips
- Use Non-ASCII only to make a source file pure ASCII while keeping it readable, for example for Java
.propertiesfiles, which traditionally needed\uXXXXfor anything outside Latin-1. - Emoji with skin tones, flags and family emoji are several code points joined together (for example 👍🏽 is U+1F44D plus the modifier U+1F3FD). The breakdown table shows every part.
- If decoded text looks like
éinstead of é, UTF-8 bytes were read as Latin-1 somewhere. Escape the garbled text with the UTF-8 style to inspect the bytes.
Frequently asked questions
What is a Unicode escape sequence?
It is a way to write a character using only plain ASCII by giving its code point in hexadecimal. For example the euro sign € is U+20AC, written \u20AC in JavaScript, JSON and Java, € in HTML and \20AC in CSS. Escapes are useful when a file, terminal or database cannot store the character directly.
Why is an emoji written as two \u escapes?
JavaScript, JSON and Java store strings as UTF-16, so characters above U+FFFF are split into a surrogate pair. 😀 (U+1F600) becomes \uD83D\uDE00. ES6 JavaScript also accepts \u{1F600}, Python uses \U0001F600, and HTML and CSS use the full code point directly.
What is the difference between \u00E9 and \xC3\xA9?
\u00E9 names the character é by its code point U+00E9. \xC3\xA9 lists the two bytes of its UTF-8 encoding, which is what you see in byte strings in Python, PHP, C and log files. This tool decodes runs of \x bytes as UTF-8 when they form valid UTF-8 and as single Latin-1 characters otherwise, so both forms come out as é.
How do I unescape \u strings in JavaScript or Python?
In JavaScript, JSON.parse('"' + s + '"') decodes \uXXXX escapes in a valid JSON string. In Python, s.encode('latin-1', 'backslashreplace').decode('unicode_escape') or codecs.decode(s, 'unicode_escape') works for ASCII input. This page does the same without code and also handles HTML entities and mixed styles.
Does escaping change the text?
No. An escape is only a different spelling of the same character. When the program reads the string, \u0041 and A are identical. Escaping only non-ASCII characters keeps your code readable while making the file pure ASCII.
How are CSS escapes written?
CSS uses a backslash followed by 1 to 6 hex digits, for example content: "\2713" for ✓. If the next character could be read as a hex digit, a space ends the escape, so this tool always adds one space after a CSS escape. The space is consumed by the parser and does not appear in the output.
Is my text sent to a server?
No. The conversion runs entirely in JavaScript in your browser. Nothing is uploaded or stored, so you can safely work with private strings, keys or log data.