Skip to content
Test versionSearch

Developer tools

Strict Unicode unit and scalar escapes

Convert every UTF-16 unit or Unicode scalar to a hexadecimal escape, or decode a sequence that contains only escapes of these kinds.

How it worksFAQRelated tools

Content reviewed:

The example values can be changed. Press Calculate to update the result; you can download it as TXT or CSV and collect scenarios in this tab. Nothing is saved or sent automatically.

Encoding writes every character as \u followed by four hex digits, or every whole character as \u{…}. Decoding accepts only such escapes in a row (lowercase u, no other text); emoji pairs are checked. The result is never run as code. Text to encode may have up to 400 characters, text to decode up to 500; a result longer than 500 characters is refused. Control characters are not accepted. You can also load a one-line UTF-8 file of up to 32 KiB. Downloads: TXT, CSV (lines that look like formulas are protected for spreadsheets), JSON and printable HTML. Nothing is saved or sent automatically.

Decimal results are approximate. Inputs stay in this browser tab.

How it works

Text is converted with the browser’s standard functions (UTF-8 encoder, JSON, String.normalize) or the RFC 4648 Base32 alphabet. Each direction is checked strictly, so invalid input is refused instead of guessed. Encoding writes every character as \u followed by four hex digits, or every whole character as \u{…}. Decoding accepts only such escapes in a row (lowercase u, no other text); emoji pairs are checked. The result is never run as code. Text to encode may have up to 400 characters, text to decode up to 500; a result longer than 500 characters is refused. Control characters are not accepted. You can also load a one-line UTF-8 file of up to 32 KiB. Downloads: TXT, CSV (lines that look like formulas are protected for spreadsheets), JSON and printable HTML. Nothing is saved or sent automatically.

Worked example

With these example values the calculator gives the result below. You can change any value in the form above.

Inputs

Direction
Encode
Escape output form
Every UTF-16 unit (four hex digits)
Text or consecutive escape tokens
Own Γ€πŸš€

Result

Encoded result
\u004F\u0077\u006E\u0020\u00E4\uD83D\uDE80
Result code points
6
Result UTF-16 units
7

Frequently asked questions

How do I convert text to Unicode escape sequences?

Choose encode and pick a layout. The Unicode escape tool writes every UTF-16 unit as backslash-u with four hex digits, or every Unicode scalar as a hexadecimal value in braces.

How are emoji written as Unicode escapes?

In the UTF-16 unit layout an emoji becomes a surrogate pair of two escapes, for example πŸš€ as \uD83D\uDE80. In the scalar layout the whole code point is written once in braces.

How do I decode Unicode escapes back to text?

Choose decode and enter a sequence made only of consecutive lower-case backslash-u tokens, either four hex digits or a braced scalar. Mixed bare text is not accepted, and surrogate pairs are validated.

How long can the text for Unicode escapes be?

Text to encode can have at most 400 UTF-16 units and escapes to decode at most 500 units. Each output is limited to 500 characters; larger expansions are refused.

Can I use a file as input for the Unicode escape tool?

Yes, an optional UTF-8 file of up to 32 KiB and 500 UTF-16 units, as one line without line endings. Encoding remains limited to 400 units.

Are the Unicode escapes the same as in Java or JavaScript?

The tool makes no claim of general Java, JSON or JavaScript language equivalence and performs no code evaluation. Invalid braced scalars and control text are refused.