Encode / Decode
Unicode Escape / Unescape
Turn every character into a four-digit escape, or turn those escapes back into text. A space is escaped too. An emoji becomes a pair of escapes.
Switch between plain text and Unicode escape sequences.
Output
—
Output actions
Ready to copy output once your result appears.
Four-digit escapes, including the space
Unicode Escape / Unescape writes every character as a backslash, a u, and four lowercase hexadecimal digits. A character that does not fit in four digits becomes two of those escapes. Decode turns a backslash and a u plus four hex digits, or a brace form, back into characters, and leaves other text alone. Encode and Decode choose the direction. Run performs it. A space is escaped. It is not left as a space.
How to escape or unescape Unicode
- 1Press Encode or Decode. Encode labels the box Plain text and uses the placeholder Hello ✓. Decode labels the box Unicode escapes. Switching the button does not run. The previous Output stays until you press Run.
- 2Paste the text or the escapes, then press Run. A success says Unicode escapes generated. or Unicode escapes decoded. Output shows the result. Copy output copies that result.
- 3There is no download and no saved draft. An empty encode succeeds with an empty Output. A failure says Unable to process the current input. and clears Output.
What it is good for
- • Turning Hello ✓ into a continuous run of four-digit escapes, including the space.
- • Reading a brace escape such as a braced emoji back into the character.
- • Leaving ordinary letters in place when you decode a string that only escapes some characters.
Example
Input
Hello ✓
Output
\u0048\u0065\u006c\u006c\u006f\u0020\u2713
H is 0048, e is 0065, each l is 006c, o is 006f, the space is 0020, and the check mark is 2713. The digits are lowercase. The placeholder on Decode shows a literal space before the check mark. That hint is not the encoded form.
How each character is written
Encode walks the text one character at a time. For a character in the range that fits in sixteen bits, it prints a backslash, a u, and exactly four hex digits, using zeros on the left when the number is small. Letters stay in that form too, so H is not left as H. The space between Hello and the check mark is \u0020, not a typed space. The check mark is \u2713. The whole sample is one continuous string with no separators.
A character above that sixteen-bit range is split into the two surrogate numbers and each is written as its own four-digit escape. The emoji 😀 encodes as 😀. Decode of that pair puts the two units back next to each other, so the emoji returns. A brace form is accepted only on decode: \u{1F600} is also the emoji, in one replacement, because the braces hold the full number. Encode never writes the brace form. It writes the pair.
Decode scans for either the brace form or a backslash, a u, and exactly four hex digits. The digits may be either case. Text that does not match is copied through. Hello \u0021 becomes Hello !. A short fragment such as \u12 has only two digits, so it is left unchanged. The page does not turn \n, \t, or \x41 into anything. Those sequences are ordinary characters here unless they happen to contain a four-digit \u form.
Encode, Decode, and Run
The direction buttons are a pair. The pressed one is the direction Run will use. Changing it updates the label and the placeholder and does not touch Output. You can prepare a new paste and press Run once. The status line starts as Switch between plain text and Unicode escape sequences. After a successful encode it reads Unicode escapes generated. After a successful decode it reads Unicode escapes decoded.
Copy output copies Output after Run. If you switch direction and forget to run, the clipboard still has the previous direction's result. There is no download. The page does not store the box. A reload returns to Encode and an empty box.
When an escape sequence is the right form
Use this page when a source file wants \u escapes, or when you have those escapes and want the characters. JSON and JavaScript strings that also escape quotes and newlines belong on string escape, which has a syntax menu this page does not. A JSON string that is itself wrapped in quotes belongs on JSON unescape. HTML entities such as named ampersands belong on HTML encode / decode. Percent-encoding for a URL belongs on URL encode / decode. None of those write this four-digit form for every character.
This page escapes the whole box, including letters and spaces. It is not a tool that escapes only the characters outside ASCII and leaves Hello as Hello. If you need the readable letters to stay, this encoder is the wrong pass.
Short escapes, braces, and characters the encoder splits
Four digits are required for the bare form. Three digits, or a \u with no digits, stay as typed on decode. The brace form allows a longer number and is how a single escape can name the emoji without a surrogate pair. Encode will not produce that brace form even if you decoded one a moment ago. Run in Encode always uses the pair for those characters.
Lowercase digits are what encode writes. Decode accepts uppercase and returns the same character. A mixed string such as ABC\u0021 keeps ABC and replaces only the escape. There is no option to escape as \U, as a brace, or as a HTML numeric entity. Those are different spellings. The failure message is generic. It does not name the bad index.
Rules and limitations
Encode writes \u and four lowercase hex digits per sixteen-bit unit. Characters that need a surrogate pair become two escapes. Spaces are escaped. The brace form is not used on encode.
Decode replaces \u{hex} and \u plus exactly four hex digits, and copies every other character through. Direction changes do not run. Copy output follows the last Run. There is no download and no saved text.
Common problems
If the space in Hello ✓ became a visible gap in your editor, you are looking at the Decode placeholder. The encoded space is \u0020.
If an emoji came back as two escapes, that is the encoder's pair. Decode accepts that pair and also the brace form. Encode will write the pair again.
Frequently asked questions
What does Hello ✓ encode to?
\u0048\u0065\u006c\u006c\u006f\u0020\u2713. The space is \u0020, not a space character. The digits are lowercase.
How is an emoji encoded?
As two four-digit escapes. 😀 becomes 😀. Decode of that pair restores the emoji. Decode of \u{1F600} restores it as well. Encode does not write the brace form.
Does Decode require the whole string to be escapes?
No. Characters that are not a brace escape or a four-digit \u escape stay as they are. \u12 is too short and is left unchanged.
Does switching to Decode run immediately?
No. Encode and Decode only choose the direction. Press Run. Until you do, Output and Copy output keep the previous result.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Next steps
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
String Escape / Unescape
Escape or unescape quotes, newlines, and backslashes for JSON, JavaScript, or SQL.
Open String Escape / UnescapeJSON Unescaper
Unwrap quoted JSON strings, including nested layers, into text or formatted JSON.
Open JSON UnescaperHTML Encode / Decode
Encode brackets, ampersands, and quotes as HTML entities, or decode them.
Open HTML Encode / DecodeURL Encode / Decode
Percent-encode or decode text with encodeURIComponent.
Open URL Encode / DecodeTrust
Policies, contact, and answers
Clear pages for how Toolbench works, what we collect, and how to reach us.