Unicode Escape / Unescape Online
Escape text to \uXXXX, \xXX, or \u{...} sequences and unescape them back, entirely in your browser.
Unicode Escape / Unescape runs entirely in your browser. The text you type or paste is never uploaded and stays on your device.
Open the HTML Entities Encoder / Decoder
About Unicode Escape / Unescape
Unicode Escape / Unescape converts text into \uXXXX, \xXX, or \u{...} escape sequences and decodes those sequences straight back into readable characters. Pick a format — JavaScript, JSON, CSS, or Python — and the tool builds the matching escape syntax for every non-ASCII character, from accented letters to emoji, including proper surrogate-pair handling for astral codepoints above U+FFFF. Toggle "Only non-ASCII" to leave plain ASCII text untouched, or escape everything for a fully sanitized string. Switch to Unescape to paste escaped text — mixed \uXXXX, \u{...}, \xXX, and \UXXXXXXXX sequences all decode correctly. Useful for debugging encoding issues, sanitizing strings in source code, or preparing JSON payloads. Everything runs locally — nothing is uploaded.
Features
- Escape text to \uXXXX, \u{...}, \xXX, or \UXXXXXXXX sequences depending on the selected format
- JS, JSON, CSS, and Python escape formats, each matching that language's real syntax
- Correct surrogate-pair output for astral characters like emoji in JSON and JS modes
- "Only non-ASCII" toggle leaves plain letters, digits, and punctuation untouched
- Unescape decodes \uXXXX, \u{...}, \xXX, \UXXXXXXXX, and CSS \XXXXXX sequences back to text
- Handles mixed escape styles in a single pasted string
- One-click copy of the escaped or decoded result
- Runs entirely in your browser — no text is ever uploaded
How to use the Unicode Escape / Unescape
- Keep the Escape mode selected and pick a format: JS, JSON, CSS, or Python
- Type or paste the text you want to escape into the left pane
- Toggle "Only non-ASCII" on or off depending on whether plain characters should stay as-is
- Copy the escaped result, or switch to Unescape and paste escape sequences to decode them back
Example
Input
Héllo → ☃
Output
H\u00e9llo \u2192 \u2603
Non-ASCII characters become \uXXXX escapes; plain ASCII letters and spaces are left as-is.
Common errors & troubleshooting
- Unescape leaves a \U escape sequence untouched. — \UXXXXXXXX requires exactly eight hex digits (Python's astral escape). Check the sequence has all eight characters after \U.
- An emoji escapes to two separate \uXXXX codes in JSON mode instead of one \u{...} code. — That is expected — JSON has no \u{...} syntax, so astral characters are represented as a UTF-16 surrogate pair. Switch to JS format for a single \u{...} escape.
- CSS escape output does not match what a stylesheet tool expects. — The CSS format here emits a fixed six-digit \XXXXXX escape. Some CSS tooling trims leading zeros or expects a trailing space before the next character — adjust as needed for your stylesheet.
- Escaping with "Only non-ASCII" off produces a much longer string than expected. — That toggle controls whether plain ASCII letters, digits, and punctuation are escaped too. Turn it back on to only escape non-ASCII characters.
Frequently asked questions
- What does the Unicode Escape / Unescape tool actually convert?
- It converts any text into \uXXXX, \xXX, \u{...}, or \UXXXXXXXX escape sequences (depending on the format you pick) and can decode those sequences back into the original characters.
- Which escape formats does Unicode Escape / Unescape support?
- JS (\uXXXX and \u{...} for astral characters), JSON (\uXXXX surrogate pairs), CSS (\XXXXXX), and Python (\uXXXX and \UXXXXXXXX for astral characters).
- How does Unicode Escape / Unescape handle emoji and other characters above U+FFFF?
- It correctly detects astral codepoints and represents them using the target format's own syntax — a single \u{...} escape in JS, a surrogate pair of two \uXXXX escapes in JSON, or \UXXXXXXXX in Python.
- What does the "Only non-ASCII" toggle do in Unicode Escape / Unescape?
- When it is on (the default), plain ASCII characters such as letters, digits, spaces, and common punctuation are left exactly as typed, and only non-ASCII characters are escaped. Turn it off to escape every character.
- Can Unicode Escape / Unescape decode mixed escape styles in one string?
- Yes. The Unescape mode recognizes \uXXXX, \u{...}, \xXX, \UXXXXXXXX, and CSS \XXXXXX sequences and decodes any combination of them found in the pasted text.
- Does Unicode Escape / Unescape upload the text I paste?
- No. All escaping and decoding happens locally in your browser. Nothing you type or paste is sent anywhere.
Related tools
All ArrayKit tools