Unicode Encode
Convert characters to \uXXXX escape sequences.
What is Unicode Encode
Unicode encoding converts characters into \uXXXX escape sequences used in string literals.
🔒 Everything runs in your browser. Nothing is uploaded.
What this tool actually does with your file
- Where it runs
- In your browser, on this page
- Upload
- None — the file never leaves your device
- Offline
- Works with the network disconnected
\uXXXX is UTF-16, not Unicode code points
The escape form \uXXXX holds exactly four hex digits, so it can only address the Basic Multilingual Plane (U+0000–U+FFFF). Characters above that — emoji, some CJK extensions, musical symbols — have to be written as a surrogate pair, two escapes that together mean one character. U+1F600 becomes 😀, and that is precisely what JSON.stringify does.
This is why a string of five emoji can produce twenty escapes: each emoji is two UTF-16 code units, and each unit is one escape. Counting escapes to estimate character length therefore overcounts by exactly the number of non-BMP characters.
Why other platforms disagree
Python, Java and C# have their own conventions: Python writes \U0001F600 with eight digits for non-BMP characters, Java uses the same surrogate-pair form as JavaScript, and PHP's json_encode by default escapes every non-ASCII character. Escapes produced in one language frequently do not round-trip in another, and the failure is silent — you get a string, just the wrong one.
If the output is going into a JSON document, do not hand-roll the escaping at all: let the serialiser do it. Hand-written \u escapes are the main source of double-escaped strings, where \\u4e2d arrives at the far end as the literal text \u4e2d.
What this encoding is good for
Turning unreadable or invisible characters into something you can inspect: zero-width spaces, line separators, non-breaking spaces, right-to-left overrides. When text looks identical but two systems disagree about whether it matches, escaping both sides and diffing the escapes finds the difference in seconds.
It is also the practical way to embed non-Latin text into environments that cannot carry UTF-8 — old config formats, some SMS gateways, and a surprising number of legacy APIs. For anything that can carry UTF-8 directly, the escapes only make the payload larger and harder to read.
How to use it
- 1.Enter text
- 2.Encode
- 3.Paste into code
How Unicode Encode works under the hood
Encoding tools convert between representations of the same bytes: Base64, percent-encoding, hex, HTML entities, Unicode escapes. A correct encoder is reversible; a lossy one silently changes the data.
- 1
Get the exact bytes
Text is encoded to UTF-8 bytes with TextEncoder first; binary input is read as an ArrayBuffer. Encoding the wrong byte sequence is the most common cause of a wrong result.
- 2
Apply the encoding rule
Each format has an exact specification: Base64 uses a 64-symbol alphabet with padding, percent-encoding escapes reserved characters as UTF-8 bytes.
- 3
Decode back to verify
Round-tripping the output back to the input is the only honest proof that an encoder is correct. The tool keeps the reverse path available on the same page.
Processing pipeline
Base64 is not encryption
Base64 increases size by about a third and hides nothing: anyone can decode it. It exists to carry binary data through text-only channels such as JSON, email headers and data URLs. If you need confidentiality, use encryption with a key, not an encoding.
Where encoders break
Percent-encoding applied twice turns %20 into %2520; Base64 without padding fails strict decoders; UTF-16 input decoded as UTF-8 produces replacement characters that cannot be recovered. When output looks wrong, check the byte sequence before checking the tool.
Verify it yourself
Encoders are pure functions over bytes. Decode the output again and you should get the input back exactly.
- 1.Open DevTools on this page and switch to the Network tab
- 2.Keep the filter on Fetch/XHR and run the tool
- 3.Confirm no request carries your file — you should see only page assets and fonts
Frequently asked questions
What is a Unicode escape?
A 6-character form like \u0041 representing one character.
Surrogate pairs?
Yes, emoji and other surrogate pairs are handled correctly.
What this kind of conversion cannot keep
Encoding and hashing run through the browser's Web Crypto API or a pure-JavaScript implementation. The output is deterministic: the same input always produces the same digest, so you can verify a result against any other tool.
More in Encoding
On this page
- What is Unicode Encode
- What this tool actually does with your file
- How it actually behaves
- How to use it
- How it works inside
- Frequently asked questions
Excel formula reference
29 functions with syntax, arguments and a table you can retype.
Browse the list →