ForHosting KIT · Developer Utilities

UTF-16 code unit converter

Type Hi and get 00480069 in big-endian order, that is two code units and 4 bytes. Switch to little-endian and H becomes 48 00 instead. Paste a hex dump to read it back as text; broken surrogate pairs are refused. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
Hi
Calculation mode
Encode
Endian
Be
You get
Result
00480069
Code units
2
Bytes
4

UTF-16 is still the wire and memory format behind Windows APIs, many binary protocols, JavaScript string internals, and interchange formats that speak in 16-bit code units rather than raw UTF-8 bytes. This tool converts plain text into a continuous hex dump of those code units—or the reverse—while you choose big-endian or little-endian layout for each unit.

What a UTF-16 code unit is and why hex helps

A Unicode scalar value in the Basic Multilingual Plane fits in one 16-bit code unit. Characters outside that plane—emoji, many historic scripts, and rare symbols—use a surrogate pair: a high surrogate in the range U+D800–U+DBFF followed by a low surrogate in U+DC00–U+DFFF. Encoding turns your text into uppercase continuous hex so every two hex digits are one byte and every four digits are one code unit under the endianness you selected.

Decoding reverses that path: whitespace, colons, underscores, and hyphens in the hex string are ignored so you can paste dumps from log lines or packet captures without a separate clean-up step. The response always reports how many code units and bytes were produced, which makes it easy to compare against a length field in a binary specification. Because the conversion is pure local parse work, identical inputs always yield identical outputs with no model drift and no network dependency.

Endianness, mode selection, and well-formedness rules

Mode defaults to encode: supply plain text and receive hex. Switch mode to decode when the input is already a hex representation of UTF-16 bytes. Endian defaults to be (big-endian), so U+0048 becomes the byte pair 00 48; choose le for little-endian 48 00, which matches many Windows and ARM memory layouts.

Endianness applies to each code unit independently; there is no automatic BOM prefix or strip—if you need a BOM you add or remove the familiar FEFF pattern yourself as explicit units. Decode requires a hex length that is a multiple of four after cleanup, because each code unit is two bytes.

During both encode and decode the stream is checked for unpaired surrogates: a high unit without a following low unit, a low unit without a preceding high unit, or a truncated pair at the end of the input all fail. That rule prevents silent corruption when a dump was cut mid-character or when a string already contained a lone surrogate.

Support and reverse engineering

Decode customer-supplied UTF-16 hex dumps back to readable text while rejecting truncated or unpaired surrogate streams.

What is the difference between be and le?

be (big-endian) stores the high byte first in each 16-bit unit; le (little-endian) stores the low byte first. Choose the layout your target format expects.

What happens on an unpaired surrogate?

No partial hex or text is returned, and the failed call is not charged.

Can I paste hex with spaces or colons?

Yes in decode mode. Spaces, underscores, colons, and hyphens are stripped before parsing. The remaining digits must form complete two-byte code units.

How does an emoji look in UTF-16?

It takes two code units, called a surrogate pair: a high half between D800 and DBFF followed by a low half between DC00 and DFFF. The hex therefore shows two units for one visible character, and both halves must stay together.

Does the tool add a byte order mark?

No. Nothing is added at the start on encode and nothing is removed on decode. If your file or protocol needs the FEFF mark, add it yourself as an explicit unit, or strip it from a dump before you paste it.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/enc/utf16

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/enc/utf16 \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hi"}'
{
  "text": "Hi"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "enc.utf16",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Surrogate pairs for characters outside the Basic Multilingual Plane stay intact; an unpaired high or low surrogate fails with a clear invalid_input error instead of producing ambiguous bytes. The same deterministic path powers the free browser form and the API at $0.002 per successful request.

What a UTF-16 code unit is and why hex helps

Debugging a protocol dump, a clipboard payload, or a mis-tagged file often means reading those units as hexadecimal rather than guessing which byte is which.

Endianness, mode selection, and well-formedness rules

Invalid mode or endian values also fail fast with a field-specific message so clients can correct the request without guessing.

Where to run it and how pricing works

For a one-off inspection—reading a UTF-16LE dump from a Windows registry export, checking how an emoji expands into two code units, or confirming that a partner’s big-endian hex matches your text—use the free in-browser tool. Because the capability is tier-A parse work, latency stays low and there is no container or model cost to re-measure after every deploy. Each successful API call costs $0.002; failed validation, including unpaired surrogates and malformed hex, is not billed, so probing bad dumps does not drain prepaid balance. Responses are deterministic JSON with the converted result, the resolved mode and endian, and counts of code units and bytes. Drop the call into a reverse-engineering notebook, a QA harness that asserts wire format equality, or a support workflow where customers paste hex and you need the readable string without opening a hex editor.

Protocol and binary format debugging

Turn human text into big- or little-endian UTF-16 hex to compare against packet captures, Windows API buffers, or specification examples.

Fixture and test data generation

Generate deterministic hex fixtures for unit tests that assert encoding length, surrogate pairs, and endian-specific layouts.

What does encode mode return?

Uppercase continuous hex of UTF-16 bytes for your text under the chosen endianness, plus code_units and bytes counts. No BOM is added automatically.

How much does the API cost?

$0.002 per successful request. The browser tool is free. Invalid input is not charged.

Read the full KIT documentation →