Encoding

Unicode Escape

Encode and decode Unicode escape sequences — characters as \uXXXX and back.

A Unicode escape sequence (\uXXXX) writes a character as its code point instead of the character itself — so a string literal in code can contain any Unicode character while the source file itself stays plain ASCII.

How to use it

Common uses

Things to keep in mind

\uXXXX encodes exactly one 16-bit UTF-16 unit, not one visible character — characters outside the Basic Multilingual Plane (most emoji) need two such sequences together (a surrogate pair).

JSON only requires escaping for control characters and a few special characters — escaping every character as \uXXXX isn't required, though it is valid.

Article about this tool: Unicode Escape: what \uXXXX sequences mean

Frequently asked questions

What does a \uXXXX escape sequence represent?

It's a Unicode code point written as four hexadecimal digits, used in JSON, JavaScript strings, and similar formats to represent a character without typing it literally.

Why do some characters like emoji turn into two \u sequences?

Characters outside the Basic Multilingual Plane (astral characters, including most emoji) don't fit in a single 16-bit \uXXXX unit, so they're represented as a surrogate pair — two \uXXXX sequences that together encode one character.

What's the difference between "Non-ASCII" and "All characters" mode?

Non-ASCII only escapes characters outside the basic ASCII range, leaving plain letters, digits, and punctuation untouched. All characters escapes everything, including ASCII, which can be useful for spotting exact character content.

What happens if a surrogate pair gets split in half?

You get an invalid "orphan" code unit — a lone code without its match. Most parsers either reject the string with an error or render a replacement-character glyph, "�".

Can an emoji character be encoded with a single \uXXXX?

No, not if the emoji lies outside the Basic Multilingual Plane (and most modern emoji do) — it always needs a surrogate pair made of two \uXXXX sequences.

Articles: Encoding

Base64: why encoding is needed and how it works

How Base64 turns binary data into ASCII text and where that is actually needed.

Base32: how it differs from Base64 and when it is more convenient

The case-insensitive Base32 alphabet and scenarios where it beats Base64.

URL Encode/Decode: percent-encoding in links

How special characters in URLs and query parameters turn into %XX sequences.

HTML Entities: how to safely output special characters on a page

Why the characters < > & need escaping and how that prevents broken markup.

JWT: token structure and what "decoding" a JWT actually means

The header, payload, and signature of a JWT, and why decoding is not the same as verifying the signature.

ROT13 and the Caesar cipher: simple character substitution

Why shifting by 13 letters makes ROT13 self-inverse, and why anyone still uses it today.

Punycode: how internationalized domains work in DNS

How a domain with non-Latin characters gets converted into an ASCII form with the xn-- prefix.

Morse code: how text becomes dots and dashes

The principle behind encoding letters as dots and dashes, and where Morse code is still used today.

Data URI: when to embed images directly in code

How a data: URI embeds a file’s contents directly in HTML or CSS, and when that is worth it.

Gzip + Base64: compressing data for text-based transfer

Why compressed binary data also gets Base64-encoded before going into a text field.

XML Entities: escaping characters in XML documents

The five required XML entities without which a document breaks during parsing.