Find the first changed and extra byte in two files
Admin ·
Find where two files first differ when a checksum or file size alone cannot tell you where to look. The comparison pairs the same byte positions and counts any remaining bytes on the longer side.
Read the three difference ranges
Select Load example and Compare bytes. The left file is 8 bytes and the right file is 10 bytes. Five shared positions match, three shared positions change and two positions exist only on the right.
The first difference is offset 2. The displayed range from 2 through 3 includes both endpoints. Its left bytes are 43 44 and its right bytes are 78 79. Offset 7 changes from 00 to FF.
| Finding | Offsets | Left hex | Right hex |
|---|---|---|---|
| Changed | 2–3 | 43 44 | 78 79 |
| Changed | 7 | 00 | FF |
| Right only | 8–9 | Absent | 0A 0D |
Download the 8-byte left exampleDownload the 10-byte right exampleW3C File API raw binary data and Blob slices
Distinguish the extra tail from changed bytes
Offsets 8 and 9 exist only in the longer file. The summary's Last difference is 9 because it includes this extra tail. The last changed shared byte remains offset 7.
Download the left sample and use it for both file inputs. Compare again. All eight positions match and the report shows no first or last difference. This control checks the same bytes even if the file names differ.
Download the 8-byte left exampleW3C File API raw binary data and Blob slices
Check the saved offsets before sharing a report
Reload the example and download binary-comparison.json. Check changedBytes is 3, rightOnlyBytes is 2 and lastDifference is 9. The ranges contain offsets and findings. File names and the hexadecimal samples remain in the workspace.
If an early difference makes most positions after it change, inspect the two files in a hex viewer. An insertion can shift later matches because the comparator always pairs equal offsets.
Download the 8-byte left exampleDownload the 10-byte right example
Common questions
Can two files of the same size have different bytes?
Yes. A same-length replacement can change any shared position while keeping the two lengths equal.
Does the range table list every difference for a large file?
The summary counts all differences. The workspace and JSON list up to the first 128 ranges.