Skip to content
AZ Tools

File Type Detector (Magic Bytes)

Reads the first 512 bytes of any dropped file in the browser and matches them against a table of ~35 well-known file signatures (PNG, JPEG, GIF, WebP, PDF, ZIP, GZIP, 7z, MP3, FLAC, MP4, MKV, WOFF2, ELF, PE, SQLite, …). Compares the detected type against the browser-reported MIME (which comes from the OS, usually from the extension) and flags mismatches — useful when checking downloaded archives, verifying that a renamed .jpg really is a JPEG, or sanity-checking user-uploaded files before processing.

How to use

  1. Drop or pick any file.
  2. Read the detected type — if it disagrees with the declared one, the badge will tell you.

Frequently asked questions

Does the file leave my browser?
No. Only the first 512 bytes are read, and only locally through the File API. Nothing is uploaded.
Why does a .docx come up as ZIP?
DOCX, XLSX, PPTX, JAR, EPUB, and OOXML are all ZIP containers under the hood. To distinguish them you'd need to inspect a specific entry inside the archive — magic-byte detection alone can't tell them apart.
The signature matches, but the file still will not open. Why?
Magic bytes only describe the beginning of a file. A download that was cut short, a binary transferred in text mode (which rewrites line endings inside the data), or a container whose payload is corrupt all keep a perfectly valid header while the rest is unusable. Detection tells you what a file claims to be, not that it is complete.
Can two formats share one signature?
Yes, and ZIP is the clearest case: .docx, .xlsx, .odt, .jar, .apk and .epub are all ZIP archives, so their real identity is decided by what sits inside rather than by the first bytes. Some formats are also identified by bytes further into the file, which is why a very short file, or one wrapped in another container, can come back unidentified.

Guides on this topic

Related tools