Skip to content
Back to all articles
Developer3 min readNovember 3, 2026

Unicode Escape Sequences Explained: \u, \u{}, U+ and HTML Entities

What \u20B9, \u{1F600}, U+0928 and ₹ mean, why emoji take two \u codes, and how to decode garbled text from APIs and JSON files.

Unicode Escape Sequences Explained: \u, \u{}, U+ and HTML Entities article
In this guide
  1. Characters, code points and encodings
  2. The common escape formats
  3. Why an emoji becomes two \u codes
  4. Hindi and other Indic scripts
  5. How to decode escaped text
  6. How to escape text for code
  7. Escapes are not URL or Base64 encoding
  8. Summary

You call an API and the response says "city": "\u092e\u0941\u0902\u092c\u0908" instead of "मुंबई". A log file is full of \ud83d\ude00. An HTML template shows ₹ where a ₹ sign should be. All of these are Unicode escape sequences: ways of writing a character by its number rather than by the character itself.

This guide explains the common formats, when each is used, and how to decode them. You can try every example in the Unicode Escape Converter.

Characters, code points and encodings

Unicode gives every character a number called a code point, written as U+ followed by hexadecimal digits:

CharacterCode point
AU+0041
éU+00E9
न (Hindi "na")U+0928
₹U+20B9
😀U+1F600

An encoding decides how those numbers are stored as bytes. UTF-8, used by most files and web pages, stores "A" in 1 byte, "₹" in 3 bytes and "😀" in 4. UTF-16, used inside JavaScript, Java and Windows, stores most characters in one 16-bit unit and characters above U+FFFF (like most emoji) in two.

An escape sequence is a way of typing a code point into code or text using only plain ASCII characters.

The common escape formats

\uXXXX (JavaScript, JSON, Java, C#)

Four hexadecimal digits: \u20B9 is ₹. This is the only escape JSON understands.

\u{X} (modern JavaScript, Swift, Rust)

Any number of hex digits in braces: \u{1F600} is 😀. Handy, but not valid in JSON.

\UXXXXXXXX (Python, C, C++)

Eight hex digits for characters above U+FFFF: "\U0001F600" in Python is 😀. Python uses \uXXXX for the rest.

U+XXXX (documentation)

How code points are written in text and specifications. Not usually understood by code.

&#xXXXX; and &#NNNN; (HTML and XML)

Character references in hexadecimal or decimal: ₹ and ₹ are both ₹.

Why an emoji becomes two \u codes

\uXXXX can only hold four hex digits, which reach U+FFFF. Emoji such as 😀 (U+1F600) are beyond that, so UTF-16 stores them as a surrogate pair of two units: \ud83d\ude00.

This is also why "😀".length is 2 in JavaScript even though you see one character. If you cut a string in the middle of a surrogate pair, you get a broken character (often shown as �).

The character breakdown table in the Unicode Escape Converter shows the number of characters and the number of UTF-16 units side by side, so these differences are easy to spot.

Hindi and other Indic scripts

A Devanagari syllable that looks like one letter is often several code points. "स्ते" is स (U+0938) + ् virama (U+094D) + त (U+0924) + े vowel sign (U+0947). So "नमस्ते", which looks like four letters, is six code points and escapes to six \u codes. That matters when you count characters, limit field lengths or reverse strings.

How to decode escaped text

  1. Open the Unicode Escape Converter and choose Unicode Escape → Text.
  2. Paste the text. It can mix \uXXXX, \u{X}, \UXXXXXXXX, U+XXXX and HTML entities, along with normal text.
  3. Every escape is decoded; the rest of the text is kept as it is.

If you regularly see escapes where you expected readable text, the usual causes are:

  • Double encoding: the text was escaped twice, so \u0928 became \\u0928. Decode in your code at the right step.
  • Showing raw JSON: the JSON was printed as a string instead of being parsed.
  • ASCII-only output settings: for example json.dumps(data) in Python escapes non-ASCII by default; json.dumps(data, ensure_ascii=False) keeps characters readable.

How to escape text for code

  1. Choose Text → Unicode Escape.
  2. Pick the format for your language: \uXXXX for JSON and JavaScript strings, \u{X} for modern JavaScript, the Python format for Python, or HTML entities for markup.
  3. Tick Escape only non-ASCII characters to keep English text readable and escape just the special characters, which is what most translation files want.

Escapes are not URL or Base64 encoding

Summary

Unicode escapes write characters by their code point: \uXXXX for JSON and JavaScript, \u{X} for modern JavaScript, \UXXXXXXXX for Python, U+XXXX in documentation and &#x…; in HTML. Characters above U+FFFF need surrogate pairs in UTF-16. To read or create any of these, use the Unicode Escape Converter, which also shows each character's code point and UTF-8 bytes.

Was this article helpful?

Found this guide useful?

Share it with someone who is struggling with the same problem.

Free tool · No sign-up

Unicode Escape Converter

Convert text to Unicode escapes (\uXXXX, \u{…}, U+, &#x…;) and decode any escape back to readable text. See every character’s code point and UTF-8 bytes.

Open tool

Written by

Hemant Adhikari HemantInsights

Senior Software Engineer · Developer of Toolyconvert

I’m a senior software engineer from Dehradun, India, building websites since 2014. I designed and developed Toolyconvert, from the Next.js front end and headless WordPress back end to the tools themselves, and I review every guide before it goes live.