Skip to content
gohacks.dev
Standard Library

Unicode Escape and Unescape

Escape text as \uXXXX, \u{...}, Python escapes, HTML numeric references, CSS escapes or percent-encoding, and unescape any mix of them back to text.

Free · No sign-up · Your inputs stay in your browser

Input

Escape and unescape Unicode

Output

Result

42 characters

JSON and older JavaScript can only write \uXXXX, so an emoji outside the Basic Multilingual Plane becomes two escapes (a surrogate pair). PHP 7+ and ES2015 accept \u{1F44D} directly; PHP only reads it inside double quotes.

Runs in this browser. Nothing you paste is sent to a server.

Surrogate pairs

JSON and pre-2015 JavaScript can only escape 16-bit code units, so a character outside the Basic Multilingual Plane, such as most emoji, is written as two escapes: 👍 is \uD83D\uDC4D. RFC 8259 section 7 defines this for JSON. ES2015 added \u{1F44D}, and PHP 7 added the same syntax inside double-quoted strings.

Reading escaped logs

PHP's json_encode() escapes non-ASCII characters by default, so logs and API responses fill with \u00e9. Pass JSON_UNESCAPED_UNICODE to keep the characters, or paste the text here to read it.

Share

Frequently asked questions

How do I write an emoji as a Unicode escape?
In modern JavaScript and PHP, \u{1F44D}. In JSON or older JavaScript, as the surrogate pair \uD83D\uDC4D.
Why does json_encode() turn é into \u00e9?
Its default is to escape every non-ASCII character. Add the JSON_UNESCAPED_UNICODE flag to output UTF-8 directly.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools