Unicode Escape Encoder
Escape a string for a source file.
About this tool
ASCII printable characters stay as themselves.
The escapes are text, not an encoding of a file.
How to use it
- Open this page and provide the input it asks for.
- Set the options that are visible, then use Escape Unicode.
- Read the result in the panel. Copy it or download it when a file is offered. The input stays in this browser.
Limitations
- The escapes are text, not an encoding of a file.
Only code points at or above 128
What is rewritten
The encoder walks code points, not UTF-16 code units. A code point below 128 is copied as itself. That includes letters, digits, spaces, newlines, quotes, and the backslash character. A code point from 128 through 65535 is written as a \u escape with four lowercase hex digits. A code point above 65535, which is where emoji and many rare characters sit, becomes a backslash, a u, an opening brace, hex without a fixed width, and a closing brace. An emoji is one escape, not a pair of surrogates, because the walk uses the full code point.
The result is a source-friendly spelling of the non-ASCII characters. It is not a file encoding, not UTF-8 bytes, and not encryption. Anyone can read the hex. ASCII that you hoped would be hidden stays on screen, including secrets that were already ASCII.
The backslash is the round-trip hazard
Because the backslash is left untouched, a paste that already contains a backslash followed by u and four hex digits is copied through. The decoder will treat that sequence as an escape. Encoding and then decoding is therefore not an identity for text that already looked like an escape, and it is not an identity for text whose only special characters were ASCII punctuation. Quotes are not escaped, so the result is not a finished JavaScript string literal. You still have to handle quotes and backslashes for that context yourself. Newlines stay newlines, so the output can be several lines.
What the decoder will add back
Non-ASCII characters this page escaped come back if you decode, with one spelling difference: the brace form and the four-digit form are just two ways to write code points, and the decoder accepts both. Characters that were left literal come back as those characters only if the decoder does not consume them as part of an escape. That is why a pre-existing escape sequence is a lossy case on this side even though this function thought it was being faithful. If you need every ASCII punctuation mark escaped, this page is not doing that job. It only touches the non-ASCII range.
Privacy
Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.

