Hex is a compact way to write byte values. It is not a different kind of stored data.
Learning Question
Why do programmers inspect bytes with hex instead of writing every byte in binary?
A byte contains 8 bits.
Writing every byte as 8 binary digits is precise, but it is visually bulky:
01001000 01100101 01101100 01101100 01101111Hexadecimal notation, usually shortened to hex, writes the same byte values more compactly:
48 65 6C 6C 6FThe stored bytes did not become “hex data.”
Hex is a notation for reading and writing byte values.
What Hex Is
Hex is base 16 notation.
It uses sixteen digit symbols:
0 1 2 3 4 5 6 7 8 9 A B C D E FOne hex digit represents 4 bits.
Two hex digits represent 8 bits.
That means one byte can be written as exactly two hex digits:
| Binary Byte | Hex | Decimal |
|---|---|---|
00000000 | 00 | 0 |
00000001 | 01 | 1 |
01001000 | 48 | 72 |
11111111 | FF | 255 |
This is why hex is convenient for byte inspection.
It lines up cleanly with byte boundaries.
Same Byte, Different Views
The byte value for the ASCII character H can be viewed several ways:
| View | Display |
|---|---|
| binary notation | 01001000 |
| hex notation | 0x48 |
| decimal notation | 72 |
| ASCII interpretation | H |
These are not four different stored bytes.
They are four views of the same value.
The prefix 0x is a common way to mark a number as hex:
0x48Without an interpretation rule such as ASCII or UTF-8, 0x48 is just a numeric byte value.
With the ASCII rule, that value maps to H.
Why Hex Is Easier Than Binary For Byte Inspection
Binary is useful when the individual bit positions matter.
For example, flags and masks are often easier to reason about in binary because each bit may have its own role.
Hex is useful when the byte values matter.
A long byte sequence is much easier to scan in hex:
48 65 6C 6C 6Fthan in binary:
01001000 01100101 01101100 01101100 01101111Hex also makes common byte patterns recognizable.
For example, many file signatures, instruction bytes, encoded text bytes, and class-file markers are written in hex because the notation is compact and exact.
Hex Dumps
A hex dump is a view of byte contents.
It usually shows:
- an offset or address-like position
- byte values written in hex
- sometimes a text interpretation column
The text column is useful, but it is not the ground truth.
The ground truth is the byte sequence.
The text column is one attempted interpretation of those bytes, often using ASCII-compatible display rules for printable bytes.
Small Experiment
These commands assume a Unix-like shell such as WSL Ubuntu.
Create a file containing the text Hello and inspect its bytes:
printf 'Hello' > hello.txt
xxd hello.txtThe exact output format may vary, but the important part should include these hex byte values:
48 65 6c 6c 6fSome tools display uppercase hex letters and some display lowercase hex letters. 6C and 6c are the same value.
What To Observe
The byte values correspond to the ASCII-compatible encoding of Hello:
| Character | Hex Byte |
|---|---|
H | 48 |
e | 65 |
l | 6C |
l | 6C |
o | 6F |
The right side of an xxd output may also show:
HelloThat right-side text is a convenience column.
It is not a second copy of the file contents.
It is a text interpretation of the same bytes shown in the hex column.
What This Proves
The file stores bytes.
Hex shows those byte values in compact notation.
The visible word Hello appears because the byte sequence is valid, printable text under an ASCII-compatible encoding.
If the same tool inspects bytes that are not printable text, the hex column can still show exact values while the text column may show dots, replacement characters, or partial readable fragments.
What Hex Does Not Mean
Hex is not a file format, a text encoding, a programming language, or a different kind of binary data.
It is a notation.
The distinction matters because it prevents statements such as:
the file is stored in hexMost ordinary files are not stored as hex text.
They are stored as bytes.
Hex is how an inspection tool may display those bytes for humans.
How To Use Hex
One byte equals 8 bits.
One byte can be written as two hex digits.
Binary, decimal, hex, and character display are different views of values, not different physical contents.
When reading a hex dump, ask:
Which part is the byte value, and which part is a tool’s optional interpretation of that value?
Hex As A Reading View
Hex makes byte values compact, stable, and readable.
It helps humans inspect exact byte sequences without pretending that those bytes already have one fixed meaning.
That is why hex becomes a practical bridge between raw bytes and higher-level interpretations such as text, file formats, bytecode, object code, and executable files.