Skip to content
ToolkitHub

Unicode Encode/Decode

Unicode encoder and decoder

Guide

Unicode escape sequences explained

By Logappradeep · ServiceNow developer

Unicode assigns a unique number, called a code point, to every character in every writing system, written as U+ followed by hexadecimal digits: U+0041 is A, U+00E9 is é, and U+1F600 is the grinning face emoji. A Unicode escape sequence is a way to write a character in source code or data using only ASCII, by spelling out its number. In JavaScript, JSON, Java, and C#, that looks like \u00E9.

How the \u format works

The \uXXXX form holds exactly four hex digits, enough for code points up to U+FFFF, the Basic Multilingual Plane. Characters beyond that range, which include most emoji and many historic scripts, are represented in UTF-16 as a surrogate pair: two escapes that together encode one character. The emoji U+1F600 becomes \uD83D\uDE00. This is also why "😀".length is 2 in JavaScript: string length counts UTF-16 code units, not characters.

Other languages use different notations for the same idea: Python also accepts \U0001F600 with eight digits, modern JavaScript accepts \u{1F600}, CSS uses \e9, and HTML uses é. The code point is the same in all of them. When decoding, this tool understands \uXXXX escapes as well as \u{1F600}, \x41, and U+00E9 notation.

Practical uses

  • ASCII-only files. Older Java .properties files, some build tools, and certain databases or terminals mishandle non-ASCII bytes. Escapes keep translations intact.
  • Finding invisible characters. A string that "looks right" but fails comparison often contains a zero-width space (\u200B), a non-breaking space (\u00A0), a byte order mark (\uFEFF), or a right-to-left override (\u202E). Encoding the text exposes every one of them.
  • Spotting look-alike characters. The Cyrillic а (\u0430) and the Latin a (\u0061) render identically but are different characters, a trick used in phishing domains and a cause of confusing bugs.
  • Reading escaped data. Logs, JSON produced with ASCII-only settings, and API responses sometimes arrive full of escapes; decoding makes them readable.

Gotchas

  • Escapes are notation, not an encoding on disk. \u00E9 is six ASCII characters that a parser interprets. The stored bytes of é in UTF-8 are C3 A9, which is a separate concept handled by the Hex encoder.
  • Normalization. é can be one code point (\u00E9) or e followed by a combining accent (\u0065\u0301). They look identical but compare as different strings unless normalized to the same form, such as NFC.
  • Broken pairs. Splitting a surrogate pair, for example by truncating a string, leaves a lone surrogate that displays as a replacement character.

Conversion runs locally in your browser and updates as you type.

Frequently asked questions

Why does one emoji turn into two escape sequences?

Emoji above U+FFFF do not fit in four hex digits, so UTF-16 represents them as a surrogate pair of two \u escapes that together form one character.

What is the difference between a code point and UTF-8?

A code point is the character's number in Unicode. UTF-8 is one way to store that number as bytes, using one to four bytes per character.

How can I find a hidden character in a string?

Encode the string here and look for unexpected escapes such as \u200B (zero-width space), \u00A0 (non-breaking space), or \uFEFF (byte order mark).

Can I use these escapes in JSON?

Yes. JSON supports \uXXXX escapes, including surrogate pairs for characters outside the Basic Multilingual Plane.