Unicode escape
Convert between text and \uXXXX escape sequences (surrogate/emoji safe)
Choose four-digit UTF-16 or braced code-point format before encoding. Use four-digit format for JSON; decoding accepts both forms.
Example
Input
中文
Example result
\u4e2d\u6587
Select the four-digit format. Decode both sequences to recover the text.
Technical details & limits
A four-digit \uXXXX escape represents one UTF-16 code unit; code points above U+FFFF need a surrogate pair. Braced escapes represent a code point up to U+10FFFF, but are not valid JSON string escapes. This tool does not replace JSON.stringify's handling of quotes and backslashes.
About this tool
Escape and unescape Unicode characters using four-digit UTF-16 sequences or braced code-point notation. Choose non-ASCII-only or all-character escaping to inspect source, configuration and logs.
Use cases
- Convert Chinese / emoji in source to pure ASCII \u escapes.
- Decode a stream of `\u5927\u7237` in logs back to readable text.
How to use
- Paste text or a string with \u escapes.
- Click Escape to encode, Unescape to decode.
Notes
Printable ASCII is left alone by default. Code points above U+FFFF use `\u{XXXXXX}` braces (not surrogate pairs).
FAQ
- Will emoji become two \uXXXX?
- Only if the target language accepts only `\uXXXX` (older JS). This tool uses `\u{...}` by default and avoids surrogate pairs.
- Why might the output not work directly in JSON?
- Braced escapes are not JSON syntax, and ordinary quotes or backslashes may still need escaping. Use a JSON serializer to create a complete JSON string.
- Does this also decode backslash-n newline escapes?
- No. It handles Unicode u escapes only. Use the target language's parser for a complete string literal.
- Why can a character produce two four-digit escapes?
- Four-digit escapes represent UTF-16 code units. Code points above U+FFFF need a high/low surrogate pair. Braced notation uses one code point but is not JSON escape syntax.
Related tools