Skip to content
Bytevive

What a file really is, whatever its name says

Drop a file and compare its extension with the signature in the first bytes. Includes a spreadsheet name on an HTML page, and a JPEG name on a HEIC header.

By the Bytevive team7 min read

A cream sheet covered in a grid of tiny hex digits with one block highlighted green, beside folders holding a spreadsheet and a page layout

The letters after a dot are a name, not a measurement. A file called budget.xlsx can be a web page, and a file called IMG_2041.jpg can be a HEIC photo from an iPhone. Programs that trust the name open the file with the wrong reader, then report a format error that sounds like damage.

The bytes at the front are the part you can check. PNG files begin with an eight-byte signature. JPEG files begin with the start-of-image marker, FF D8. ZIP files, including every modern Word, Excel, and PowerPoint document, begin with PK. MP4, MOV, and HEIC files are all ISO base media files: a box named ftyp near the start carries a brand such as isom, qt, or heic. HTML has no magic number, but a file that starts with <!DOCTYPE html is not a spreadsheet.

What the first bytes say

The name is a label. The signature is the start of the file. This reads at most the first 1,024 bytes, on this device.

The first sample is a short HTML page named budget.xlsx. The name promises an Excel workbook. The bytes start with a tag. That is the situation behind Excel’s “file format or file extension is not valid” message when someone renamed a download, and it is not something a repair tool should pretend to fix. The second sample is only a HEIC file header, not a photograph, named as a JPEG. Windows Photos will not treat those bytes as a JPEG, because they are not one. See how to tell a renamed Excel file from a broken one and why HEIC photos will not open on Windows.

What a match does not prove

A matching signature only says the file starts the way that format starts. It does not say the rest arrived. A JPEG that was cut off still begins with FF D8, and the missing end is a different problem, covered in how a JPEG tells you it is not finished. A ZIP that begins with PK can still be missing the central directory at the end.

This page reads at most the first 1,024 bytes, in your browser. It does not upload the file, and it does not try to repair it. When the name and the bytes disagree, renaming the file to match the bytes is the honest first step. When they agree and the file still will not open, the damage is further in, which is what the repair tools are for (free account, in your browser, nothing uploaded).

Frequently asked questions

Does a matching signature mean the file is undamaged?
No. The signature is only the opening bytes. A JPEG can start with FF D8 and still be cut off halfway down, and a ZIP can start with PK and still be missing its central directory.
Why does Excel say the format or extension is not valid?
Excel trusts the extension enough to try to open the file as a workbook, then checks the bytes. A web page, a CSV, or an old .xls that was renamed to .xlsx will fail that check. The lab on this page shows the renamed-web-page case.
Is a .docx supposed to look like a ZIP?
Yes. A .docx, .xlsx, or .pptx is a ZIP package of XML parts. A PK signature on a file with one of those names is a match, not a mismatch.
How can I see the first bytes of a file without this page?
On Windows, run Format-Hex on the file in PowerShell. The first line of output is the first 16 bytes. On a Mac, xxd in Terminal does the same. Compare the opening pairs with the signatures above: 89 50 4E 47 for PNG, FF D8 for JPEG, 50 4B for ZIP.
My photo ends in .jpg but the lab says HEIC. What now?
Work on a copy and rename it to .heic, so the name matches the bytes. Windows still needs a HEIF decoder to show it, which Microsoft documents as the HEIF and HEVC extensions for the Photos app. The other route is to export the photo as a real JPEG from the device that took it.

Sources

Every claim, error message, price, and limit cited above comes from these pages, checked on December 1, 2026. If one has changed, tell us at support@bytevive.com and we’ll update the article.

  1. PNG specification: file signature
  2. ITU-T T.81: JPEG start of image marker
  3. ISO/IEC 14496-12: ISO base media file format (ftyp box)
  4. Library of Congress: ISO Base Media File Format (the ftyp box)
  5. PKWARE APPNOTE: ZIP format
  6. Microsoft: Office Open XML file formats
  7. Microsoft Support: A file is in a different format than its extension indicates in Excel
  8. Microsoft Support: Photos app needs HEIF and HEVC extensions
  9. Microsoft PowerShell docs: Format-Hex

Document won't open? See what's still in it.

Free account, Word, Excel, and PowerPoint files up to 512 MB. Nothing is uploaded.

Repair a document, free

Other free tools: video, PDF, photo, Office, ZIP, and audio repair.