Hex to text converter
Convert hex bytes to text and back across UTF-8, UTF-16, UTF-32, Latin-1, ASCII, GBK and GB18030, with BOM detection, optional BOM output and a mojibake diagnosis that pinpoints the first invalid byte.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
Everything runs locally; your input is never uploaded.
Enter something to see the result
GBK / GB18030 use a built-in real code table: all 23940 double-byte code positions are covered, and the GB18030 four-byte area is mapped back through 210 linear ranges for characters outside the BMP.
What this tool does
- You have a hex dump from a packet capture, a serial log or a database and want to know whether it is UTF-8 or GBK: pick the encoding and, if it fails, see exactly which byte is invalid.
- Encode Chinese text for a GBK / GB18030 protocol field or a legacy system in one step instead of looking code points up by hand.
- Debug mojibake: feed the bytes in and let the diagnosis tell you which encoding was probably read as which.
- Handle BOMs: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE and UTF-32BE are recognised, can be stripped on decode and prepended again on encode.
Example
Input
E4 BD A0 E5 A5 BD
Output
你好
Decoded as UTF-8. Read as GBK the same bytes become "浣犲ソ", the classic mojibake the diagnosis warns about.
Frequently asked questions
Which encodings are supported, and both ways?
Nine, all bidirectional: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE, Latin-1 (ISO-8859-1), ASCII, GBK and GB18030. The UTF codecs are hand-written so they can tell an invalid byte from a truncated sequence; Latin-1 maps bytes 0x00–0xFF straight to U+0000–U+00FF without the Windows-1252 substitutions.
How complete is the GBK / GB18030 table?
The double-byte area is complete: the built-in table covers 0x81–0xFE lead bytes times 0x40–0x7E and 0x80–0xFE trail bytes, 23940 code positions in total, matching the WHATWG Encoding Standard gb18030 index (including the PUA block and the 2005 revisions such as 0xA8BC → U+1E3F and 0xFE50 → U+2E81). The GB18030 four-byte area is implemented as 210 linear ranges covering the 1087995 code points of U+0080–U+10FFFF that the double-byte area does not use; the remaining 499605 four-byte pointers are invalid sequences in the standard and raise invalid-byte. GBK has no four-byte area, so characters outside the BMP (U+20000, emoji) fail with unsupported-char under GBK and need GB18030.
How does the mojibake diagnosis guess an encoding?
It strictly decodes the bytes with all nine encodings and scores readability (CJK and printable characters add, control characters, private-use area and U+FFFD subtract). The highest scoring encoding that differs from the one in use becomes the guess, e.g. C4 E3 BA C3 fails on byte 0 as UTF-8 and the tool says it looks like GBK read as UTF-8. It is a heuristic, not proof.
How are BOMs handled?
UTF-8 (EF BB BF), UTF-16LE (FF FE), UTF-16BE (FE FF), UTF-32LE (FF FE 00 00) and UTF-32BE (00 00 FE FF) are recognised, longest prefix first, so FF FE 00 00 is UTF-32LE rather than UTF-16LE. Auto mode picks the BOM encoding and strips the BOM; choosing another encoding explicitly keeps the BOM and warns about the mismatch. On encode you can prepend a BOM; Latin-1, ASCII, GBK and GB18030 have none, so the option is ignored with a note.
Which inputs are errors, and what do the codes mean?
invalid-hex for a non-hex character, odd-hex-length for an odd number of digits, truncated-sequence for an incomplete multi-byte sequence, invalid-byte for a byte that is illegal in the chosen encoding, unsupported-char when the encoding cannot represent a character, empty-input for nothing entered. The diagnosis reports the offset of the first invalid byte; switch "Invalid bytes" to replace and the tool continues, counting the replacements.
Does it compress, encrypt or auto-detect the encoding?
No to all three. This is a pure codec: no decompression, no decryption, and auto mode only follows a BOM — without one it assumes UTF-8 instead of guessing statistically (guessing only appears as a hint in the diagnosis). Everything runs locally in the browser and nothing is uploaded.
Keywords:hex to texthex decoderGB18030UTF-16mojibakecharset converter