Codec lesson · Base16 / Hex
Base16 / Hex: read every UTF-8 byte directly
Base16, commonly called hexadecimal or Hex, writes every byte as two symbols from 0–9 and A–F. It is direct and readable when inspecting bytes.
Completed in this browser
Connect one byte to two hexadecimal digits and identify incomplete pairs or byte sequences that are not valid UTF-8 text.
Encode Keyboard writes canonical uppercase Base16 with no separators. Decode accepts upper- or lowercase hex and ASCII whitespace, then requires complete byte pairs and valid UTF-8.
How Encode Keyboard handles it
Create UTF-8 bytes
Each input character becomes one or more bytes under UTF-8.
Split each byte in half
The high and low four-bit values each map to one hexadecimal digit.
Validate byte pairs
Decode rejects non-hex symbols, odd digit counts, and bytes that do not form valid UTF-8 text. An initial U+FEFF is preserved.
Worked example
Hi4869H is byte 0x48 and i is byte 0x69, so each input byte occupies exactly two hex digits.
Good uses
- Inspecting UTF-8 bytes compactly
- Comparing text with byte-level logs
- Learning how binary nibbles map to hexadecimal
Validation and common errors
- Use only digits 0–9 and letters A–F or a–f
- Provide an even number of digits after optional whitespace is removed
- Remember that valid byte pairs may still be invalid UTF-8 text
Practice in your browser
This uses the same documented rules as the app and runs only in this tab.