πŸ“‹ Convert to Unicode Escapes

Convert text characters to Unicode escape sequences (\\uXXXX format). This tool is useful for developers working with internationalization, JSON encoding, programming, and handling special characters in code.

πŸ“Œ Unicode Escape Sequences:
Type or paste text to see Unicode escape sequences...
Characters: 0
πŸ’‘ What are Unicode Escapes? Unicode escape sequences represent characters using the format \uXXXX where X is a hexadecimal digit:
  • Each character is converted to its Unicode code point
  • Format: \u followed by 4 hexadecimal digits
  • Example: "A" becomes "\u0041"
  • Useful for encoding special characters and non-ASCII text

πŸ“ Examples:

Input:
Hello
Output:
\u0048\u0065\u006c\u006c\u006f
Input:
δ½ ε₯½δΈ–η•Œ (Hello in Chinese)
Output:
\u4f60\u597d\u4e16\u754c
Input:
CafΓ©
Output:
\u0043\u0061\u0066\u00e9
πŸ“š Use Cases:
  • Encoding international text in JavaScript and JSON
  • Creating string literals with special characters in source code
  • Storing non-ASCII characters in configuration files
  • Debugging character encoding issues
  • Internationalization (i18n) and localization (l10n)
  • Working with Unicode in HTML and XML documents
ℹ️ Format Details: This tool uses the standard JavaScript Unicode escape format (\uXXXX). Each character is represented by exactly 4 hexadecimal digits.

How each escape is built

The text is split into UTF-16 code units, and every unit - not just the exotic ones - is written out as a four-digit hexadecimal escape in lower case:

for each code unit c:
    '\u' + c.charCodeAt(0).toString(16).padStart(4, '0')

"Cafe" written with an acute accent gives \u0043\u0061\u0066\u00e9. Nothing is skipped, so plain letters, spaces and line breaks are escaped too, and the output runs six characters for every character you typed. That is the format JavaScript, JSON and Java all understand.

What the awkward characters produce

InputOutput
A\u0041
space\u0020
line break\u000a
e-acute, precomposed\u00e9
e-acute, decomposed\u0065\u0301
grinning face emoji\ud83d\ude00

The last two rows are the ones that surprise people. An accent typed as a separate combining mark is a second code unit and gets its own escape, so visually identical text can produce different output. Anything above U+FFFF - emoji, rare CJK, musical symbols - is stored as a surrogate pair and comes out as two escapes, which is exactly how JavaScript holds it internally.

The counter reports code units, not characters you can see. One emoji is reported as 2, and the copy button fails quietly with an alert if the box still holds its placeholder text.

Frequently asked questions

How do I write an emoji as a Unicode escape?

Paste it in and use the surrogate pair it returns - the grinning face is \ud83d\ude00. Modern JavaScript also accepts the code point form \u{1F600}, but JSON does not, and this tool always emits the pair.

Are these escapes valid in JSON?

Yes. \uXXXX with exactly four hex digits is the only escape JSON defines for characters, and a parser turns it straight back into the original text, so an escaped string is a safe way to keep a config file pure ASCII.

How do I convert Unicode escapes back into text?

This tool only goes one way. To reverse it, wrap the output in double quotes and run it through JSON.parse in a browser console, or paste it into a string literal in your code and print the result.