Skip to main content

File Type Checker: Identify Any File by Its Contents (Magic Bytes)

Drop a file to find out what it really is.

The checker reads its magic bytes in your browser, names the format and MIME type, shows the first 32 bytes in hex, flags an extension that does not match (such as a program renamed .pdf), and looks inside ZIP files to tell docx, xlsx, jar, apk and epub apart.

Nothing is uploaded.

Last updatedHow we build & check our tools

Interactive Tool

Loading interactive tool…

Enter your values once it appears to see your results.

Results will appear here once the tool finishes loading. Everything runs locally in your browser.

How the checker identifies a file

The extension is just part of the name, and anyone can change it. The contents are harder to fake. Most binary formats start with a fixed run of bytes, called a magic number or file signature, so the program that opens the file can check it is the right kind. A PNG always begins 89 50 4E 47 0D 0A 1A 0A. A PDF begins with the text %PDF-. A Windows program begins MZ.

The checker reads the first 64 KB and the last 66 KB of the file with your browser's File API and tests them in this order:

  1. Trailers: a few formats are marked at the end, such as an Apple disk image's koly block 512 bytes from the end.
  2. Containers with a type field: RIFF files carry WAVE, AVI or WEBP at byte 8, and MP4, MOV, HEIC and AVIF carry a brand after ftyp at byte 4.
  3. Fixed signatures, longest first, so the 8-byte RAR 5 header wins over the 7-byte RAR 4 one. Some sit far from the start: ustar at byte 257 for tar, CD001 at byte 32,769 for an ISO disc image.
  4. A look inside: ZIP files are opened to read their entry names, Matroska files to read the DocType, and Office 97-2003 files to find their stream names.
  5. Text heuristics when nothing else matches: no NUL bytes, valid UTF-8, then a check for JSON, XML, SVG or HTML.

The table on this page lists all 98 signatures and 35 container rules, drawn mainly from Gary Kessler's File Signatures Table, with MIME names from the IANA Media Types registry.

Three worked examples

The page has these built in as example buttons, so you can see each result without a file of your own.

File nameFirst bytesResult
holiday-photo.jpg89 50 4E 47 0D 0A 1A 0A (".PNG....")PNG image, image/png. The extension does not match: a JPEG starts FF D8 FF. Harmless, and most viewers open it anyway, but some upload forms reject it. Rename it .png.
Invoice_2026-10.pdf4D 5A 90 00 ("MZ..")Windows program (PE/MZ). A red warning: this is an executable named like a document, a classic malware trick. Do not open it.
quarterly-report.docx50 4B 03 04 ("PK..")The bytes only say ZIP. The entry list holds [Content_Types].xml and word/document.xml, so it is a Word document and the extension matches.

Each result also gives the evidence (which bytes matched and at what offset), the usual extensions for that format, and a hex dump of the first 32 bytes. The copy button puts all of it on the clipboard as plain text for a ticket or an incident note.

Why docx, xlsx, jar, apk and epub all start with PK

Dozens of formats are ZIP archives with a set layout inside. They share the ZIP local file header signature 50 4B 03 04 ("PK", for Phil Katz, who wrote PKZIP). To tell them apart, the checker reads the archive's central directory from the end of the file, as described in PKWARE's ZIP specification, and looks for the entries each format requires:

FormatWhat identifies it inside the ZIP
docx, xlsx, pptx[Content_Types].xml plus a word/, xl/ or ppt/ folder (ECMA-376 Open Packaging)
epubA first, uncompressed entry named mimetype containing application/epub+zip
odt, ods, odpThe same mimetype entry, naming an application/vnd.oasis.opendocument.* type
jarMETA-INF/MANIFEST.MF
apkAndroidManifest.xml with classes.dex or resources.arsc
ipaA Payload/<name>.app/ folder
xpi, whl, nupkg, kmz, 3mfinstall.rdf or META-INF/mozilla.rsa; *.dist-info/WHEEL; a .nuspec; doc.kml; 3D/3dmodel.model

Office 97-2003 files (doc, xls, ppt, msg) share another container, the Microsoft Compound File, which starts D0 CF 11 E0 A1 B1 1A E1. The checker tells them apart by stream names such as WordDocument or Workbook.

What this check cannot tell you

  • It is not an antivirus. A real PDF or Word file can still carry a malicious macro or exploit. A matching extension tells you what the file is, not that it is safe. Scan anything suspicious with your security software.
  • Plain text formats have no signature. CSV, TXT, Markdown, source code and most config files are just text, so they all show as plain text. JSON, XML, SVG and HTML are recognised from their opening characters.
  • Short signatures can collide. MP3 frame sync (FF FB) and BMP (BM) are two bytes long. The checker adds a sanity test for BMP, but random data can still look like an MP3.
  • One file can be valid as two types. A self-extracting archive is a Windows program with a ZIP appended, and the checker reports the program, which is the part that runs.
  • Some containers are only partly read. ZIP64 archives over 4 GB, encrypted files and Office 97-2003 files whose stream names sit beyond the bytes read fall back to the generic type (ZIP or Compound File).

Frequently Asked Questions

Common questions about the File Type Checker: Identify Any File by Its Contents (Magic Bytes)

Drop it on this page. The checker reads the file's first bytes, its magic number, and compares them with 98 known signatures, so it can name a file that has the wrong extension or none at all. On Linux and macOS the file command in a terminal does the same job using the libmagic database.

From the same team

Turn your GPU into an OpenAI-compatible API endpoint

Wide Area AI routes your LLM API calls to your own hardware over a Cloudflare Tunnel — free local inference with edge caching and automatic cloud failover. Works with any OpenAI SDK.

Start routing — free

Sources & References

File Signatures Table

Main source for the magic numbers and offsets in the signature table.

Media Types

The registry of official MIME type names reported for each format.

APPNOTE.TXT: .ZIP File Format Specification

Local file header, central directory and end-of-central-directory layouts used to read ZIP entry names.

ECMA-376 Office Open XML File Formats

The [Content_Types].xml package layout that identifies docx, xlsx and pptx.

EPUB 3.3: OCF ZIP container

The uncompressed first mimetype entry that identifies an EPUB.

[MS-CFB]: Compound File Binary File Format

The D0 CF 11 E0 header and directory used by Office 97-2003 files and MSI installers.

File (command) and libmagic

The magic(5) convention of testing longer, more specific patterns before shorter ones.

List of file signatures

Cross-check for signatures not in the Kessler table, such as QOI, JPEG XL and Zstandard.