π 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.
\uXXXX where X is a hexadecimal digit:
- Each character is converted to its Unicode code point
- Format:
\ufollowed by 4 hexadecimal digits - Example: "A" becomes "
\u0041" - Useful for encoding special characters and non-ASCII text
π Examples:
- 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
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
| Input | Output |
|---|---|
| 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.
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.