Home Tools Blog About

Escape Unicode

In short

Escape Unicode characters as JS, JSON, Python, HTML, or CSS sequences - or unescape any of them. Free, offline, client-side, instant, secure.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up

Convert any text containing non-ASCII characters (accented letters, emoji, CJK, math symbols) into the escape sequence your target language expects - \u{1F389}, 🎉, \U0001F389, 🎉, or \1F389. Or paste an escaped string and decode it.

- paste text to begin
🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use Escape Unicode

  1. Pick a mode. Match it to the target language. Use js-modern for ES6+ JavaScript source files. Use js-surrogate when your output is JSON, or when you need surrogate pairs (older JavaScript runtimes, jq, awk-style processors). Pick python, html-hex, html-dec, or css as appropriate.
  2. Paste your text in the input. Output updates live (150 ms debounce). By default only non-ASCII characters are escaped - ASCII passes through.
  3. Toggle "also escape ASCII" if you need every character escaped (e.g. obfuscation, or systems that mangle even printable ASCII).
  4. Read the stats line - selected format, input → output character counts, count of escape sequences emitted (escape mode) or decoded (unescape mode).
  5. Unescape works on mixed input. The auto-detector recognises all six escape forms in any combination - paste a snippet with , 🎉, and 41 all mixed and it decodes each.
  6. Copy or download. Ctrl/Cmd + Enter copies. Download writes escaped.txt or unescaped.txt.

Frequently Asked Questions

What is Unicode escaping and when do I need it?

An escape converts a character to a backslash-prefixed (or entity-prefixed) text representation of its code point: becomes in JavaScript, € in HTML, or 20AC in CSS. You need it when the output channel can’t represent the character directly – older code editors that mangle UTF-8, build systems that strip non-ASCII, JSON serialisers that prefer ASCII output, source files committed to environments with unknown encodings, or string literals in languages that don’t accept literal Unicode in source.

What’s the difference between the JavaScript modes?

js-modern uses ES6’s u{XXXX} form for astral-plane characters (U+10000 and above), which keeps each emoji as one escape: 🎉 → u{1F389}. js-surrogate emits the older uXXXX form using UTF-16 surrogate pairs, so emoji become two escapes: 🎉 → 🎉. JSON requires the surrogate-pair form – the u{} syntax is not valid JSON. Pick js-modern for application source, js-surrogate for JSON output or any context that needs to round-trip through a JSON parser.

How are emoji handled?

Emoji are encoded as a single code point above U+FFFF. The tool iterates by code point (using for…of), not by UTF-16 code unit, so each emoji produces one escape in formats that support astral planes (js-modern, python, html-hex, html-dec, css) and a surrogate pair in formats that don’t (js-surrogate). Variation selectors (FE0F) and ZWJ sequences (200D) are escaped as separate code points – that’s correct.

Why does the CSS escape have a trailing space?

The CSS escape rule says HEX consumes up to 6 hexadecimal characters from the input that follows. So if the character after the escape is itself a hex digit, the parser glues them together. A trailing space (which CSS subsequently swallows) prevents that. Example: escaping A next to a literal 0 becomes 41 0 not 410.

Does the unescape mode handle mixed inputs?

Yes. The auto-detector runs six independent regex passes – one per escape form (u{X}, UXXXXXXXX, uXXXX with surrogate-pair re-combination, &#xHH;, &#NNN;, CSS HEX). Anything that doesn’t match a known form is left intact, so plain text mixed with escapes round-trips cleanly.

What about right-to-left scripts and combining marks?

Each Unicode code point is treated as a separate unit. Arabic, Hebrew, and Indic scripts work – every character produces its own escape. Combining marks (like the accent on é when stored as e + U+0301) escape as two separate sequences. If you want the precomposed form, normalise with NFC first (String.prototype.normalize('NFC') in the browser console).

Can I escape every character (including ASCII)?

Yes – toggle “Also escape ASCII characters”. This is useful for fully ASCII-safe output (e.g. building a JSON string where you want every character escaped) or for obfuscation. By default ASCII passes through verbatim because that’s what nearly every real use case wants.

Is my data secure?

Yes. The page loads three static files (HTML, CSS, JS) and then runs entirely in your browser. Your input never leaves the device – no fetch, no XHR, no analytics, no cookies. You can disconnect from the internet after the page loads and the tool still works.

Is this tool free?

Yes – free, unlimited, no signup, no watermark. Use the output anywhere. Attribution to is appreciated but not required.

Keep going

Related Tools

All Unicode tools →
Share

Embed this tool

Add this free tool to your website. Copy and paste the code: