Unicode Escape & Unescape

Convert text to \uXXXX escape sequences and back, with surrogate pairs handled and invisible characters made visible.

Escaping is a reversible representation, not encryption. Everything runs in your browser and nothing is uploaded.

What It Does

Turns text into escape sequences that are pure ASCII, and turns them back again. The immediate use is transport: escaped text survives build pipelines, older APIs and misconfigured database clients that would otherwise mangle anything outside ASCII. The less obvious use is diagnosis, and it is often the more valuable one. Zero-width spaces, non-breaking spaces and byte-order marks are invisible on screen and quietly break string comparisons, slugs and search — escaping makes each of them a distinct visible code. The tool handles surrogate pairs correctly, so an emoji round-trips exactly, and offers both the universal four-digit form and the ES6 braced form, which matters because JSON accepts only the former.

When to Use It

  • Two strings look identical but will not compare equal, and you need to see which invisible character is different.
  • An API or legacy system accepts only ASCII and your payload contains accented text or emoji.
  • A build step is mangling non-ASCII characters and you want to pass them through as escapes instead.
  • You are writing a test fixture and want the exact characters visible in the source rather than relying on file encoding.
  • A configuration value keeps breaking and you suspect a byte-order mark or a non-breaking space pasted in from a document.

Worked Examples

café

The straightforward case. Only the accented letter is escaped, becoming \u00e9 — the plain ASCII letters are left alone, because escaping them would triple the length for no benefit.

Hello 😀

The surrogate pair case. The emoji sits above FFFF so the four-digit form needs two sequences, \ud83d\ude00. Switch to the braced form and it becomes the single \u{1f600}.

price:​ 100

This looks like ordinary text and is not — there is a zero-width space after the colon. Escaping exposes it as \u200b, which is usually the explanation when a value refuses to match or a lookup silently fails.

Features

Escape to \uXXXX or the ES6 \u{...} form
Unescape back to the original text
Surrogate pairs handled correctly for emoji
Invisible characters revealed and named
Escape only non-ASCII
everything
or non-printing only
Byte-order mark and zero-width space detection
Character and byte counts alongside the result
Accepts mixed escaped and plain input when decoding
Swap direction in one click
Runs entirely in your browser

How to Use

1. Choose a direction — escape or unescape. 2. Paste your text or your escape sequences. 3. The result appears immediately, with a note about anything invisible that was found. 4. Pick the escape form: four-digit for JSON and maximum compatibility, braced for readability. 5. Copy the result, or swap to send it back the other way.

Common Mistakes

  • Putting \u{...} into JSON. JSON only accepts the four-digit form, so the braced version is a parse error however valid it is in JavaScript source.
  • Splitting escaped text between the halves of a surrogate pair. Each half is meaningless alone, so truncating between them produces an invalid character rather than a shorter string.
  • Treating escaping as obfuscation. It is a reversible representation like hex — anyone can read it, and nothing about it is private.
  • Escaping everything by default. It works but bloats the output several times over and makes the result far harder to review.
  • Assuming text that looks clean is clean. Zero-width and directional characters are invisible by design, and escaping is often the only practical way to find them.

Frequently Asked Questions