Convert UTF-16 Text to Hexadecimal: What It Changes and When It Helps

How UTF-16 to hex conversion works, why byte order and surrogate pairs matter, and when hex output is useful or when plain text is better.

Converting text to UTF-16 hexadecimal turns each character into the numeric code units a computer stores for it, written in base 16. A tool that does this does not restyle the text or make it more readable. It exposes the encoding underneath. That is useful for some jobs and unhelpful for others, so this review covers what the conversion actually produces, where results can differ between tools, and how well the output holds up when it is copied or shared.

Is UTF-16 to hex the right transformation for your purpose?

Hex conversion is a good fit when you need to see exactly what is stored rather than what is displayed. Typical cases include debugging encoding errors, comparing two strings that look identical but behave differently, writing byte-level test data, checking file contents against a specification, and passing text through a channel that only accepts plain ASCII characters.

The main benefit is precision. Hex shows every code unit, including invisible characters, combining marks, byte order marks and the two halves of an emoji. The decisive tradeoff is readability. People cannot read the output as language, search engines and in-page search will not match it against the original words, and screen readers have no way to recover the meaning from it.

Plain text is the better choice whenever the goal is communication, such as messages, posts, documents, labels or anything a person or assistive technology needs to read. Use hex as a diagnostic or transport layer, and keep the original text available alongside it.

What the conversion actually changes

Nothing about the characters themselves changes. The conversion replaces a readable string with a written-out view of its UTF-16 encoding. UTF-16 represents each Unicode code point as one or two 16-bit code units. Characters in the Basic Multilingual Plane, which includes most Latin, Cyrillic, Greek, CJK and common symbol characters, use one code unit. Characters above U+FFFF, such as most emoji, use two code units known as a surrogate pair.

The phrase "UTF-16 to hex" can describe several different outputs. Before relying on any converter, check which one it produces:

  • Code units: one four-digit hex value per 16-bit unit, for example 0048 0069 for "Hi".
  • Big-endian bytes (UTF-16BE): each unit written high byte first, for example 00 48 00 69.
  • Little-endian bytes (UTF-16LE): each unit written low byte first, for example 48 00 69 00.
  • Bytes with a byte order mark: FE FF placed before big-endian data, or FF FE placed before little-endian data.
  • Escape notation: the same code units formatted for source code, such as \u0048\u0069.
  • Code points instead of code units: some tools list U+1F600 for an emoji instead of its UTF-16 surrogate pair, which is not UTF-16 output at all.

Separators (spaces, commas, none), letter case (D83D or d83d) and prefixes (0x) are cosmetic. Byte order, the presence of a BOM, and code units versus code points are not cosmetic. These choices change the value, and decoding with the wrong assumption produces the wrong characters.

Worked examples

The table below shows how a few characters encode. The UTF-8 column is included because UTF-8 is the encoding most often confused with UTF-16 when people ask for "text to hex."

Character | Code point(s) | UTF-16 code units | UTF-16BE bytes | UTF-16LE bytes | UTF-8 bytes
H | U+0048 | 0048 | 00 48 | 48 00 | 48
é (precomposed) | U+00E9 | 00E9 | 00 E9 | E9 00 | C3 A9
é (e + combining acute) | U+0065 U+0301 | 0065 0301 | 00 65 03 01 | 65 00 01 03 | 65 CC 81
€ | U+20AC | 20AC | 20 AC | AC 20 | E2 82 AC
😀 | U+1F600 | D83D DE00 | D8 3D DE 00 | 3D D8 00 DE | F0 9F 98 80
👍🏽 | U+1F44D U+1F3FD | D83D DC4D D83C DFFD | D8 3D DC 4D D8 3C DF FD | 3D D8 4D DC 3C D8 FD DF | F0 9F 91 8D F0 9F 8F BD

Two points from these examples matter in practice. First, the two forms of é look the same on screen but produce different hex, because one is a single code point and the other is a base letter followed by a combining mark. If you compare hex dumps to find out whether two strings are "the same," normalize both strings first (for example to NFC) or you may report a false difference. Second, what looks like one emoji can be several code points. The thumbs-up with a skin-tone modifier is two code points and four UTF-16 code units, and emoji joined with zero-width joiners grow longer still.

Byte swapping is not reversal

Converting between big-endian and little-endian swaps the two bytes inside each code unit. It does not reverse the text. Reversing the order of code units does not produce reversed text either. Reversing D83D DE00 gives DE00 D83D, which is an unpaired low surrogate followed by an unpaired high surrogate. That sequence is not valid UTF-16, and decoders will either reject it or substitute replacement characters. The same problem affects combining marks. Reversing 0065 0301 moves the accent in front of its base letter. Any reversal has to operate on whole grapheme clusters, never on hex units or bytes.

Checking a converter yourself

If you are unsure what an online converter outputs, the result can be reproduced locally. The Python snippet below makes byte order explicit. The plain utf-16 codec adds a BOM and uses the machine's native byte order, which is why the endian-specific codecs are usually the safer choice.

text = 'Hi😀'

print(text.encode('utf-16-be').hex(' ').upper())
# 00 48 00 69 D8 3D DE 00

print(text.encode('utf-16-le').hex(' ').upper())
# 48 00 69 00 3D D8 00 DE

# Round trip back to text
print(bytes.fromhex('00 48 00 69 D8 3D DE 00').decode('utf-16-be'))
# Hi😀

In JavaScript, strings are already sequences of UTF-16 code units, so charCodeAt returns them directly. Iterating with for...of or Array.from would yield code points instead and would hide the surrogate pair.

const s = 'Hi😀';
const units = [];
for (let i = 0; i < s.length; i++) {
  units.push(s.charCodeAt(i).toString(16).toUpperCase().padStart(4, '0'));
}
console.log(units.join(' '));
// 0048 0069 D83D DE00

Will the result stay usable after copying or sharing?

As a string, hex output is unusually robust. It contains only the digits 0 to 9, the letters A to F and whatever separators the tool adds, so it survives copy and paste, email, chat and plain-text fields without the font substitution or rendering gaps that affect styled Unicode text. The fragile part is the context, not the characters. A recipient who receives the hex without knowing the byte order, whether a BOM is included, and whether the values are code units or code points may decode it incorrectly. When you share hex, state the format next to it, for example "UTF-16BE, no BOM."

Some transport steps can still damage hex. Line wrapping can split a code unit across lines. Automatic formatting may add characters. Tools that treat the input as a number may strip leading zeros, which turns 0048 into 48. Check that the length is consistent after transfer: four hex digits per code unit, or two per byte.

For accessibility, search and editing, hex is a replacement for meaning, not a presentation of it. A screen reader can only announce the digits and letters. Search will not find the original words. Editing a single character requires recalculating its encoding by hand. Whenever people need to read, find or change the content, provide the plain-text original, and treat the hex as supplementary technical detail.

Privacy and evidence gaps

Hex is an encoding, not encryption. Anyone can decode it in seconds, so converting sensitive text to hex does not protect it. Whether a particular online converter processes text in the browser or sends it to a server cannot be determined from how the tool looks or how it describes itself. For confidential text, a local method such as the snippets above avoids the question entirely.

This review is based on the UTF-16 encoding rules and the worked examples above. It does not include tests of specific converter tools, messaging platforms or assistive technologies, and no such results were available. Before depending on a particular tool or destination, confirm its output format against a known example, such as the 😀 row in the table, and check a round trip back to text.