Shard Tools

Unicode Escape

Convert text into Unicode escape sequences in your browser, handling characters above the basic plane.

Maintained by Roshan.

Use Unicode Escape

Converts text to escaped in this tab, with nothing sent anywhere.

Runs entirely on your deviceThe conversion happens in this browser tab. Nothing you type is uploaded, logged or stored, which is worth knowing for anything you would not paste into a search box.

Explore developer and data tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all developer and data tools

About Unicode Escape

A Unicode escape sequence writes a character as a code like backslash-u followed by its hex code point, and it exists for the places where a raw character cannot safely appear. Source code that must stay pure ASCII, a JSON string being embedded somewhere fussy, a config file whose encoding you do not trust: in all of them, escaping the non-ASCII characters sidesteps the question of whether the file's encoding will survive. The subtlety that trips up naive tools is characters above the basic multilingual plane - emoji, some scripts, rarer symbols - which do not fit in the four-hex-digit form and are stored internally as two halves. A tool that escapes each half produces sequences that decode to broken characters. This one walks the text by code point and uses the longer brace form for those characters, so they round-trip correctly.

Using Unicode Escape

  1. The text is walked by code point rather than by character unit, so a character above the basic plane is treated as one thing, not two halves.
  2. Printable ASCII is left as it is, since the point is to escape only what needs escaping.
  3. A character within the basic plane is written as a four-hex-digit escape.
  4. A character above the basic plane - an emoji, for instance - is written in the brace form that can hold its longer code point.
  5. The result is text safe to place where only ASCII is welcome, and it decodes back exactly.

Where unicode escape helps

Keeping source code ASCII-only

Escaping the non-ASCII characters lets a string containing accents or emoji live in a file that must remain plain ASCII.

Embedding text somewhere encoding-fragile

When you are not sure the destination preserves UTF-8, escaping the risky characters avoids the question entirely.

Before you use the result

Questions about Unicode Escape

Why are emoji written with braces?

Because they are above the basic plane and do not fit the four-digit form. The brace form holds the longer code point and decodes correctly.

Does it escape ordinary letters?

No. Printable ASCII is left alone; only non-ASCII characters are escaped.

Will it round-trip?

Yes, through the unicode unescape tool, because high characters use the correct longer form.

Is this the JavaScript escape format?

It uses the common backslash-u convention, including the brace form for high code points that modern JavaScript supports.

Related tools

Unicode Unescape

Convert Unicode escape sequences back into readable characters in your browser.

HTML Entity Encoder

Encode text as HTML entities in your browser so it displays as text instead of being interpreted as markup.

Text to Hex

Convert text to hexadecimal in your browser. Each character becomes its UTF-8 bytes in hex.