The display

How a hex editor works

A hex editor is a view onto a numbered list. Position 0 is the first byte of the file. Position 1 is the next. The number of a byte, counted from the start, is its offset. Editors usually print offsets in hexadecimal too, so 10 means sixteen bytes in, not ten.

The three columns

Almost every hex editor lays a row out the same way. On the left, the offset of the first byte in that row. In the middle, the bytes themselves, almost always sixteen of them, because sixteen is a round number in hex (0x10). On the right, those same sixteen bytes interpreted as text.

OffsetHex bytesText column
00000000  89 50 4E 47 0D 0A 1A 0A  00 00 00 0D 49 48 44 52  .PNG........IHDR
The start of a PNG image. The letters PNG are visible. The bytes around them are part of the format, not part of a sentence.

Why hexadecimal

You could write every byte in decimal, from 0 to 255. Hex is used because a byte is eight bits, and each hex digit is four bits, so one byte is always exactly two digits. 0A and FF take the same space. Decimal 10 and decimal 255 do not, and the columns would wobble.

The prefix people write in prose, 0x, is not stored in the file. It only marks a number as hexadecimal when it appears in a sentence. Inside the editor the digits stand alone.

Editing is changing a number

If you change 48 to 4A in the word Hello, the H becomes a J, because those two numbers are the codes for those two letters. The editor did not edit a document. It replaced one byte with another.

The same kind of replacement inside a photo or a database can make the file unreadable, because that byte was a length, a checksum, or part of a compressed stream. The editor has no way to know the difference. The format does.

What the editor is not showing you

The display answers “which bytes are here?” It does not answer “what do they mean?” A four-byte integer, a date, and a short string can all look like four ordinary hex pairs until you know which one you are on. Templates exist for that next step: you describe the fields once, and the editor labels them instead of leaving you to count.