Unicode Escape Encoder & Decoder
Encode text as \uXXXX, \xXX, or HTML hex entities, and decode escaped strings back to readable text for code, JSON, and config work.
This conversion runs only in your browser — nothing is uploaded.
\uXXXX uses UTF-16 code units (emoji → surrogate pairs). Hex is UTF-8 bytes (\xXX). HTML is &#x…; numeric entities.
- Input0
- Output0
- OptionsUnicode (\uXXXX)
Input
Output
What is this tool?
This Unicode escape encoder and decoder converts readable text to escape notations used in JavaScript/JSON strings, byte-level debugging, and HTML numeric entities — then decodes them back.
- Unicode (
\uXXXX) — UTF-16 code units (JSON / JS string style). Supplementary characters such as emoji become surrogate pairs. - Hex (
\xXX) — UTF-8 bytes, useful when a log shows raw byte escapes. - HTML (
&#x…;) — hexadecimal numeric character references.
Escaping is not encryption. Anyone can reverse the result. Conversion updates live and stays in your browser.
Common use cases
- Read
\uXXXXsequences from API or application logs - Prepare JSON/JS string escapes that include CJK or emoji
- Compare UTF-16 escapes with UTF-8
\xXXbytes for the same character
How to use
- Choose Encode or Decode. Results update as you type; changing the format re-runs immediately.
- Pick Unicode, Hex, or HTML to match the source you are debugging.
- Paste text or escapes. Sample loads
안녕 😀(or the matching escaped form). - Copy the output. Meta chips show character counts and a short U+ code-point preview.
Examples
| Input / setting | Output | Notes |
|---|---|---|
Hi → Unicode encode | \u0048\u0069 | Each BMP character becomes one \uXXXX. |
Hi → Hex encode | \x48\x69 | UTF-8 bytes for ASCII (same values as code points here). |
\uD83D\uDE00 → Unicode decode | 😀 | Surrogate pair → U+1F600 (edge vs single \uXXXX). |
A → HTML decode | A | Hexadecimal HTML entity back to a character. |
Mixed logs and invalid input
Only the selected escape syntax is decoded. Ordinary text stays intact: Hex mode turns status=\xec\x95\x88;ok into status=안;ok. An incomplete byte run such as \xec\x95 shows an error instead of silently producing replacement characters. Other encodings such as Latin-1 are not supported by Hex mode.
The Unicode mode reads four-digit UTF-16 units. \uD83D\uDE00 forms 😀; \u{1F600} is JavaScript syntax outside this mode. Quotes and \n remain literal text: decode a full JSON document with a JSON parser.
Practical pitfalls
- Surrounding text is preserved. Malformed selected escapes and invalid UTF-8 byte runs show an error; choose the matching format.
\uXXXX: UTF-16;\xXX: UTF-8;&#x…;: Unicode.
Continue the workflow
For a complete JSON document, use the JSON formatter and validator rather than treating quotes and backslashes as plain text. After decoding, count the UTF-8 bytes of the readable result to check an API or form limit.
References
Last reviewed: 2026-10-11
Frequently asked questions
- Why does an emoji become two \uXXXX escapes?
- JavaScript and JSON \uXXXX escapes are UTF-16 code units. Characters outside the Basic Multilingual Plane (including many emoji) need a high/low surrogate pair, for example \uD83D\uDE00 for 😀 (U+1F600), not a single four-digit escape.
- What is the difference between Unicode, Hex, and HTML formats?
- Unicode mode emits \uXXXX (UTF-16 units). Hex mode emits \xXX for each UTF-8 byte. HTML mode emits hexadecimal numeric entities like 😀. Pick the format that matches the log, language, or markup you are reading.
- Why does decoding fail or look empty?
- The selected format must match the input. Pasting \u escapes while Hex is selected, truncated surrogate pairs, or incomplete \x / &#x…; sequences will not decode cleanly. Switch format or fix the escapes.
- Does the text leave my browser?
- No. Encoding and decoding run only client-side.
- Why does an incomplete UTF-8 hex sequence show an error?
- Hex mode decodes contiguous byte escapes as UTF-8. For example, \xec\x95 is incomplete and fails; it is not Latin-1. Ordinary surrounding text is preserved, and unselected escape formats stay unchanged.