Text to Unicode

Converter

Convert text to Unicode escape sequences (\uXXXX) and back for UTF-16. Ideal for debugging encoded strings and inspecting raw code points in one pass.

Converted
Plain text
8 chars
Unicode escapes
48 chars

About Text to Unicode

Working with emoji, rare characters, or multilingual strings often means needing a character's Unicode code point, or turning an escape like \u4f60 back into text. This tool converts text to and from Unicode code points (U+XXXX and various escape forms) locally in your browser, handling characters beyond the basic plane such as emoji. Type the Chinese character 你 and you will see code point U+4F60, UTF-8 bytes E4 BD A0, and its CJK Unified Ideographs block.

Code point and byte sequence are two layers and mixing them misreads results. A code point is the character number in the standard, independent of encoding, while a byte sequence is its actual form in a file, where one code point occupies different byte counts under different encodings. Saying how long a character is requires naming the layer — characters, code points or bytes — which diverge sharply on text with CJK or emoji.

Characters beyond the basic plane need a surrogate pair, the most error-prone part of escape forms. Common escapes record only four digits, so a character numbered beyond that range needs two consecutive units, neither of which alone is a complete character. Splitting a string into four-digit groups therefore cuts emoji or rare CJK characters in half.

There are more escape forms than expected and conversions must state which is produced. One code point may be written as a U-plus notation, a backslash escape, a decimal entity or a hexadecimal entity, each suiting a different context: the first for human reading, the rest for embedding in a language or markup. A converter must be explicit about the form, or the recipient may read it by another rule.

Invisible characters are where this conversion most often raises security issues. A set of letters looks identical to ordinary ones but differs in code point — for example across writing systems — and can build strings that look indistinguishable yet differ in content, defeating a naive comparison. For identifier or domain checking, normalise first and compare strictly by code point, not by sight.

Normalisation is a necessary step for text from multiple sources. One visible character can have several code point compositions, such as an accented letter encoded as a single composed point or as a base letter plus a combining mark. Without normalising, two strings that look the same compare as different, a common and hard-to-locate symptom when aggregating text from different systems.

Finally, the typical use is diagnosis rather than authoring. Its value is turning a difference you cannot see into one you can, such as confirming whether two variable names are truly identical or finding an invisible character in a config. Treat it as a diagnostic and, once found, fix the text with normalisation in an editor rather than carrying escapes long term.

How It Works Internally

Escaping writes a character as a code point such as backslash-u plus four hex digits. Two things matter: characters outside the basic plane are written as two surrogate halves in some languages, and reading them one by one yields the wrong character; and escaping is only a notation, so the target language must unescape with the same rule, since treating it as a plain string shows the sequence literally.

InputThe character A
Output\u0041 (four hex digits); characters beyond the basic plane require two surrogate halves

Measured on This Page

ForwardAll six match the UTF-16 code-unit form: 中文测试 → \u4e2d\u6587\u6d4b\u8bd5
Emoji splits🔑 becomes \ud83d\udd11 — two code units, which is exactly how JS strings store it, not an error
Combining marksa plus U+0301 converts as two separate units without merging
Reverse\u4e2d\u6587, the surrogate pair \ud83d\udd11 and \u{1f389} mixed in one line all restore correctly
Empty inputProduces nothing in either direction and no error

The output is UTF-16 code units, not Unicode code points: emoji 🔑 (U+1F511) becomes two \u escapes. That matches how JS and Java actually store strings, so pasting into source code of those languages works directly — but Python 3 and Rust work in code points and want \U0001F511 or \u{1F511} instead, so do not move 4-digit escapes across unchanged. The parser accepts both \uXXXX and \u{1F511}.

How this was measured: Six forward inputs (ASCII, Chinese, emoji, accented, combining, empty) were converted and compared against expectations derived independently from UTF-16 code units (text.encode('utf-16-be'), two hex digits per 16-bit unit); the reverse direction mixed \uXXXX, surrogate pairs and \u{...} in one string. · Measured 2026-10-29

How to Use

  1. Open "Text to Unicode"
  2. Switch to "Text → Unicode"
  3. Type text to get \uXXXX escapes
  4. Emoji split into surrogate-pair halves
  5. Click the copy icon to take the escaped string

Use Cases

  • Look up code points — See a character's U+ code point to confirm it is the intended one.
  • Unescape sequences — Turn \uXXXX escapes in source code back into readable text to review content.
  • Generate escapes — Convert a string with special characters into \u escapes to embed safely in JSON or code.
  • Spot lookalikes — Use code points to distinguish similar glyphs (full-width vs half-width) and catch input traps.
  • Diagnose mojibake — Read code points to judge if a character was mis-encoded and trace garbled text.
  • Build regex patterns — Get the code point of a character to build a precise Unicode range for a regex pattern.
  • Verify normalization — Compare NFC and NFD code point sequences to confirm a string is in the expected normalization form.

FAQ

Why does an emoji sometimes show two values?

Characters above U+FFFF are represented by a surrogate pair in UTF-16. The tool shows the true code point and converts correctly between code points and surrogate pairs.

Which escape formats are supported?

Common \\uXXXX (four hex digits) and U+XXXX notation; for high code points, a brace-extended form is also supported, which helps with emoji.

How are combining characters handled?

They may consist of several code points. The tool expands the actual sequence, so one visible glyph can map to multiple U+ values — this is normal.

Are code points decimal or hex?

Unicode code points are conventionally hexadecimal with a U+ prefix. The tool outputs hex by default, matching the standard.

I want 0/1 binary instead.

This gives character code points; for a UTF-8 byte-based binary bit string, use our text to binary tool.

Fancy fonts turn into boxes or question marks on other platforms?

Fancy styles use the Unicode mathematical letter block (U+1D400+), which not every platform's fonts cover — chat apps are the least reliable. Test on the target platform before using them in titles or usernames.

The text grew after escaping — can it be restored exactly?

Yes, escaping is reversible: \uXXXX maps back to one character and surrogate pairs back to one emoji, provided both directions use the same basis (UTF-16 code units vs Unicode code points). Mixing the two corrupts character boundaries.

Why do different tools give different code points for the same character?

Some Han characters have compatibility variants: the same glyph exists at multiple Unicode code points (the unified block and the compatibility block). Different sources (IMEs, fonts) may land on different ones — visually identical but encoded differently. Normalise (NFC/NFKC) for search and indexing.