Unicode Escape / Unescape

Escape text as JavaScript, JSON, Python, C, CSS, HTML or URL escape sequences, or turn escapes like \u00e9, \u{1F600} and 😀 back into readable text.

Converter Text & Encoding Updated Oct 3, 2026
How to Use
  1. Choose Escape to turn characters into escape sequences, or Unescape to turn sequences back into characters.
  2. Pick the language or format: JavaScript/JSON, ES6 code points, Python, C/C++, CSS, HTML (hex or decimal), URL or U+ notation.
  3. Choose whether to escape only non-ASCII characters (the usual choice) or every character.
  4. Unescaping recognises all the formats at once, so a string that mixes \u00e9, \x41, é and %C3%A9 comes out as plain text.
Input
Presets
Characters
Characters
—
Non-ASCII
—
Escaped
—
Result length
—

Worked Example

Escape 😀 (U+1F600) for a JavaScript string.

It is above U+FFFF, so UTF-16 needs two code units. Subtract 0x10000: 0x1F600 − 0x10000 = 0xF600.
High surrogate: 0xD800 + (0xF600 >> 10) = 0xD800 + 0x3D = 0xD83D.
Low surrogate: 0xDC00 + (0xF600 & 0x3FF) = 0xDC00 + 0x200 = 0xDE00.
So the escape is \uD83D\uDE00, and "😀".length is 2 in JavaScript.

The same character is \u{1F600} in ES6 and Rust, \U0001F600 in Python and C, \1F600 in CSS, 😀 in HTML and %F0%9F%98%80 in a URL.

Show Work

Type something above to see how its characters are escaped.

Formulas

High surrogate
0xD800 + ((cp − 0x10000) >> 10)
For code points above U+FFFF
Low surrogate
0xDC00 + ((cp − 0x10000) & 0x3FF)
The bottom 10 bits
Back to a code point
(hi − 0xD800) × 0x400 + (lo − 0xDC00) + 0x10000
What unescaping a pair does
Python
\xXX · \uXXXX · \UXXXXXXXX
Up to FF · up to FFFF · above
CSS
\HEX followed by a space
The space is needed only before another hex digit or space

Why There Are So Many Escapes

Every language invented its own way to write a character it could not type. C used \x for bytes in the 1970s, and C99 added \u and \U universal character names. Java (1995) and then JavaScript adopted \uXXXX when Unicode still fit in 16 bits; when Unicode grew past 65,536 characters in 1996, UTF-16 surrogate pairs were added, and those languages have written emoji as two escapes ever since.

ES2015 added \u{…} with a whole code point, as Rust and Swift do. HTML had numeric character references from the start, and URLs settled on percent-encoding the UTF-8 bytes in RFC 3986 (2005).

About This Tool

This tool escapes text in nine formats and unescapes all of them at once, including surrogate pairs, \u{…} code points, Python \U, runs of \x bytes, HTML numeric references, percent-encoded UTF-8 and U+ notation. The character table shows each character’s code point, its UTF-16 units and its escape.

Broken sequences, such as a lone surrogate or an incomplete %-escape, are left as they are and pointed out. Everything runs in your browser.

Related tools: Unicode Lab, HTML Entity Encoder, and URL Encoder / Decoder.

Frequently Asked Questions

Why does 😀 become two \u escapes in JavaScript?

JavaScript, JSON, Java and C# store text in UTF-16, where characters above U+FFFF are split into a surrogate pair. 😀 is U+1F600: subtract 0x10000 to get 0xF600, then the top 10 bits give the high surrogate D83D and the bottom 10 bits give the low surrogate DE00, so it is written \uD83D\uDE00. Modern JavaScript also accepts \u{1F600}, but JSON does not.

Which escape format should I use?

Use the one for the place the text will be pasted: JavaScript or JSON strings take \uXXXX; Python takes \xXX, \uXXXX and \UXXXXXXXX; C and C++ take \u and \U; CSS content takes \ followed by hex; HTML takes &#x…; and URLs take %XX bytes of UTF-8. They all describe the same characters; only the spelling differs.

What does “escape only non-ASCII” mean?

Characters 0–127 — English letters, digits and basic punctuation — are left as they are, and only accented letters, symbols and emoji are escaped. That keeps the result readable and safe in files or systems that only handle ASCII. Control characters such as new lines are always escaped in string formats.

Why did unescaping \xc3\xa9 give é and not é?

A run of \x escapes that forms valid UTF-8 is read as UTF-8 bytes, which is how Python shows bytes and how most logs print them. If the bytes are not valid UTF-8, each \xXX is read as one character instead (U+0000–U+00FF), and the tool says which reading it used. Reading UTF-8 bytes one character at a time is exactly what produces mojibake like é.

Is this the same as HTML entity encoding or URL encoding?

Those are two of the formats here, applied to non-ASCII characters. For full HTML escaping with named entities such as é, use the HTML Entity Encoder; for complete URL and query-string encoding, use the URL Encoder.

How do I use the Unicode Escape / Unescape?

Simply type or paste your value and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Do I need to install or sign up for anything?

Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.

Is my information private?

Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.

Common Use Cases

Source code and JSON

Put “café ☕” into a JavaScript or JSON string that must stay ASCII: caf\u00e9 \u2615.

Reading logs and dumps

Turn a log line full of \u00f6 or \xc3\xb6 escapes back into readable text in one paste.

CSS icons and content

Write an em dash or arrow in a CSS content property as \2014 or \2192, which works in any stylesheet encoding.

Debugging emoji

See why a string with one emoji has a .length of 2 in JavaScript: the surrogate pair is shown step by step.

Last updated: