Unicode escape converter
Convert text to Unicode escapes or decode supported JavaScript-style escapes into readable text.
- 1Add input
- 2Adjust settings
- 3Get your result
Tool input and files are processed in this browser without being uploaded.
Before you start
Convert Unicode text to JavaScript-style \u escapes, or decode supported backslash escape sequences into text. Processing happens in your browser. Copy the complete result or download it as result.txt.
How to use this tool
- Paste ordinary text or supported backslash escapes into Text. Under Options, choose Encode or Decode in Operation.
- For Encode, leave Keep printable ASCII except backslash checked to retain printable ASCII characters. Clear it to escape every UTF-16 code unit. This option is hidden when decoding.
- Select Convert Unicode escapes and check the characters, backslashes and quotation marks. Use Copy result for the full text or download result.txt. Convert again after changing the input or options.
Supported inputs and limits
Paste up to 1 MiB of text, measured in UTF-8 bytes. This tool has no file input.
Encoding uses UTF-16 code units, so a character above U+FFFF is written as two \u escapes. Unpaired surrogates are rejected during encoding and after decoding.
The converter works on text contents as supplied. It does not remove surrounding quotation marks or parse a JavaScript or JSON document. Check the escape rules required by the destination.
Worked example
Example input
A中文😀
Example options
{}Example output
A\u4e2d\u6587\ud83d\ude00
When something does not work
Check the original text for a trailing backslash, unsupported escape or incomplete hexadecimal sequence. Use two backslashes to represent one literal backslash when decoding. Keep surrogate pairs together and code point values within the supported Unicode range. Editing the input marks the previous result as stale, and a failed run clears it. Copy or download any result you need before refreshing or closing the tab.
Frequently asked questions
Which escapes can Decode read?
It reads four-digit \uHHHH sequences, \u{...} code point escapes with one to six hexadecimal digits, and two-digit \xHH sequences. It also recognizes \n, \r, \t, \b, \f, \v, \0, escaped backslashes, quotation marks and slashes. A \0 escape cannot be followed by a digit. Unsupported or incomplete escapes cause an error.
Is the result ready to paste into a quoted string?
Check the destination's quoting rules first. With the default encoding option, printable ASCII quotation marks stay unchanged, while backslashes and control characters are escaped. The converter does not add surrounding quotes or check a complete JavaScript string literal or JSON document. The result panel displays the output as text.
Documentation & further reading
Related tools
Base64 encoder and decoder
Encode text or file bytes as Base64, or decode Base64 to UTF-8 text or a binary file.
URL encoder and decoder
Percent-encode or decode a URL component or whole URL, with optional plus-to-space decoding.
HTML entity encoder and decoder
Encode special HTML characters, or decode named and numeric references as plain text.
SHA-256 checksum
Calculate a SHA-256 checksum for text or a file.