Unicode Encoder
Turn text into Unicode escape sequences for JavaScript, JSON, ES6, Python, CSS and HTML, or list the U+ code points of every character.
Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.
How to use the Unicode Encoder
- 1 Type or paste your text.
- 2 Choose the format of the language or file you need it in.
- 3 Copy the escaped text.
About the Unicode Encoder
Unicode gives every character a number, its code point, written as U+ and four to six hexadecimal digits: U+00E9 for é and U+1F600 for 😀. Escape sequences let you write those characters using only ASCII, which is useful in source code, JSON, CSS and configuration files.
JavaScript and JSON use \uXXXX. Characters above U+FFFF, such as most emoji, need two such escapes, a surrogate pair (😀 is \uD83D\uDE00). ES6 JavaScript also accepts \u{1F600}, Python uses \U0001F600 for those characters, CSS uses a backslash with up to six hex digits, and HTML uses é or é.
By default only non-ASCII characters are escaped, so the text stays readable. Turn on "Also escape ASCII" to escape every character. The code point format always lists every character. The Unicode Decoder converts all these formats back.
Frequently asked questions
Why does an emoji become two \u escapes?
JavaScript and JSON strings are UTF-16. Characters above U+FFFF don’t fit in one 16-bit unit and are written as a surrogate pair of two escapes.
What is a code point?
The number Unicode assigns to a character, written as U+ followed by hex digits. é is U+00E9, the euro sign U+20AC.
Which format should I use in JSON?
The JavaScript/JSON format (\uXXXX). JSON doesn’t support \u{…}.
Is this the same as UTF-8?
No. UTF-8 is how code points are stored as bytes. To see those bytes, use Text to Hex.