Text to UTF-16 code units
Type text to see the UTF-16 code units that JavaScript, Java and Windows use internally for strings.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter text and format.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
Up to U+FFFF one unit equals the code point. Above: v = cp − 10000, then D800 + (v ÷ 400) and DC00 + (v mod 400), in hex.
Example
Inputs: Format = Code units (0633). Result: UTF-16: D83D DE00; Code units: 2; Bytes: 4.
😀
D83D DE00
Limits and caveats
- No byte order mark (FE FF or FF FE) is added to the output.
Questions about this tool
Why does an emoji give two units?
Its code point is above FFFF, so it is written as a surrogate pair: a high unit from D800 and a low unit from DC00.
What is the difference between BE and LE?
BE puts the high byte first (06 33) and LE puts the low byte first (33 06). Windows usually uses LE.
Why is a JavaScript string length different from the character count?
JavaScript length counts UTF-16 units, so 😀 has length 2.
