Skip to content
Files

4 min read

Check a File Type Beyond Its Extension and MIME Label

Compare filenames, declared MIME types, and supported file signatures while understanding what these clues can and cannot prove.

By GoldieKit · Published

A file extension, MIME label, and byte signature compared side by side

A filename ending in .png is a claim about a file, not proof that its bytes form a PNG image. A browser or operating system may also report a MIME type such as image/png, but that label can come from the source or surrounding metadata rather than a deep inspection of the file. GoldieKit's File type inspector compares extension and MIME metadata with supported magic bytes. Use the signals together to spot inconsistencies, not to certify that a file is harmless.

What each signal tells you

An extension is part of the name and is easy to change. A declared MIME type is a label supplied by a system or sender and may be missing or wrong. Magic bytes are recognizable byte patterns near the beginning of some file formats. They can reveal that a file looks like a PNG, PDF, ZIP, or another supported type. But a matching signature does not prove the entire file is valid, safe, or complete. Files can be truncated, malformed, or contain unexpected additional data.

Suppose an attachment named report.pdf has ZIP-like leading bytes. It may be mislabeled, an archive with the wrong extension, or a special container format. Do not just rename it and open it. Ask the sender what was intended, inspect it with a trusted tool, and avoid executing unknown contents. An office document may itself use a ZIP container internally, so a ZIP signature alone does not tell the whole story.

Signal Easy to change? Useful for
Filename extension Yes Human expectation and default app selection
Declared MIME type Often How a system says it will handle the file
Magic bytes Harder to fake accidentally Recognizing supported format signatures
Full parse Depends on parser Checking structural validity

Inspect locally with GoldieKit

Open File type inspector and select a local file. Compare the extension, declared MIME value, and detected signature. If they disagree, pause before uploading or opening the file in a privileged application. File metadata viewer can show name, size, modified date, and format clues; these are observations, not provenance guarantees.

For a file you received by email, check whether the sender expected that format and whether the file opens in an appropriate viewer. Do not upload a suspicious file to a random online scanner just to identify it; that can disclose its contents. GoldieKit's inspection runs in the browser tab, but application code still needs to load and browser limits still apply.

Type does not equal safety

A genuine PDF can contain links, form actions, or complicated structures. A genuine ZIP can contain many files and expand much larger than its compressed size. A real image can be malformed and stress an image decoder. Knowing the type helps you choose a safe workflow; it does not replace cautious handling. Keep the operating system and viewers updated and avoid opening files from untrusted sources in applications with unnecessary privileges.

A file hash answers a different question. File hash checker computes SHA-256 and can compare it with an expected value. A matching hash shows byte-for-byte agreement with that expected value, assuming a trusted source supplied it. It does not identify the file format or prove that the source was trustworthy. The checksums article explains this boundary.

Common mismatches

An image exported as WebP but named .jpg may display in a browser yet fail in a system that relies on extensions. A downloaded JSON response saved as .csv may look like data but have a completely different structure. A .zip archive with a misleading name may be blocked by a mail service. Check whether the mismatch comes from a mistaken export, a rename, or an unexpected response from a server.

If a server sends the wrong Content-Type, the browser may treat the file differently from what the extension suggests. The appropriate fix is to correct the server response and file naming, not to assume one label will always override the other. For local workflows, re-export from the source application with the intended format and extension when possible.

A practical decision path

If the signals agree and the file comes from a trusted source, open it with a suitable viewer and inspect whether its content is plausible. If they disagree, verify the source and re-export before passing it to a tool. If the file is sensitive, keep inspection local. If exact bytes matter, compare a trusted checksum. Treat extension, MIME, and signature as complementary clues; none is a complete trust certificate.

Example: a download that is really an error page

Suppose a download button saves manual.pdf, but the file is only a few kilobytes and the inspector does not recognize a PDF signature. Open it as plain text only if that is safe in your environment; it may contain an HTML error page or login response saved under the intended filename. The fix is to return to the source website and resolve the download or authentication issue. Renaming the file to .pdf again cannot create missing PDF bytes. This is one reason to inspect size and signature before sharing a failed download with someone else.


Put the ideas to work

Focused guides

For a shorter, step-by-step walkthrough:


Keep exploring

All guides