Guides

File Extension vs MIME Type: Key Differences & Comparison Table

A file extension is the suffix in a filename (.pdf, .jpg) — a human-facing label that can be changed or wrong. A MIME type is the media type a program declares and acts on (application/pdf, image/jpeg). The authoritative answer to “what is this file really?” is neither — it’s the file’s magic bytes, the signature at the start of its contents. These three describe a file’s type in different ways, and knowing which to trust prevents a lot of confusion.

This guide explains each, why they can disagree, and why tools that read files rely on the contents rather than the name. See also the supported file formats list.

File extension: a label in the name

The extension is just the text after the last dot in the filename. It tells your operating system which program to open the file with, which is why double-clicking report.pdf launches a PDF reader. But the extension is only a label — nothing forces it to match the contents. Rename photo.jpg to photo.txt and the pixels don’t change; only the hint does. This is why extensions can lie, by accident (a mislabelled download) or on purpose (disguising a file).

MIME type: the media type a program acts on

A MIME type (also called a media type or content type) is a standard two-part label like type/subtype — application/pdf, image/png, text/csv. It’s the language the web and applications use to say what a file is, independent of its name. When you download a file, the server sends a Content-Type header carrying its MIME type, and your browser uses that to decide how to handle it. MIME types are more precise than extensions, but they can still be set incorrectly by whatever produced the file.

Magic bytes: the real proof

The trustworthy signal is inside the file. Most formats begin with a fixed signature — “magic bytes” — that identifies them regardless of name or declared type:

  • %PDF — a PDF
  • PK (0x50 0x4B) — a ZIP, and therefore also .docx, .xlsx, .pptx and .epub, which are ZIP-based
  • ÿØÿ — a JPEG
  • ‰PNG — a PNG
  • MZ — a Windows executable (.exe, .dll)

Reading the first few bytes tells you what a file genuinely is. This is how a robust tool decides how to process a file — not by trusting the extension.

Why the difference matters

  • Mislabelled files. A file saved with the wrong extension still opens correctly in a tool that checks its contents, even though a double-click might fail.
  • Security. Because extensions can be faked, relying on the name alone to decide a file is “safe” is a classic mistake; content inspection is the defence.
  • Extraction. An extractor that reads magic bytes can tell a real .xlsx (a ZIP) from an old binary .xls even if both are named the same, and route each correctly.

Frequently asked questions

What is the difference between a file extension and a MIME type?
The extension is the suffix in the filename (a label for the OS); the MIME type is the media type a program declares and acts on (like application/pdf). The extension names the file; the MIME type describes its content.

Can a file’s extension be wrong?
Yes. The extension is only a label and can be changed or mislabelled without altering the contents. The file’s magic bytes reveal its true type.

What are magic bytes?
A fixed signature at the start of a file that identifies its format regardless of the filename — for example %PDF for a PDF or PK for a ZIP-based file.

Why do DOCX and XLSX start with “PK”?
Because they are ZIP archives of XML, and PK is the ZIP signature. Their real type is confirmed by the parts inside the archive.

Which should I trust to identify a file?
The magic bytes. Extensions and even declared MIME types can be wrong; the file’s own signature is authoritative.

Last updated: 16 August 2026.

About Abrar

Abrar builds EasyExtract's free, browser-based extraction tools and writes these guides on getting data out of files — PDFs, spreadsheets, images, archives and Office documents. Every tool runs entirely in your browser, so nothing you open is ever uploaded.

Keep reading