Tips & Tricks 4 min readMarch 17, 2026
How to Detect File Formats — Beyond the Extension
File extensions can be wrong or missing. Learn how to detect the true format of any file using magic bytes.
Why File Extensions Cannot Be Trusted
A file named "document.pdf" might actually be:
- A renamed JPEG image
- A Word document with a wrong extension
- A ZIP archive
- Even an executable file
File extensions are just labels — they do not change the actual file content.
How File Detection Works
Every file format has "magic bytes" — specific bytes at the beginning of the file that identify its type:
| Format | Magic Bytes | Hex |
|---|---|---|
| JPEG | Start with FFD8FF | FF D8 FF |
| PNG | Start with 89504E47 | 89 50 4E 47 |
| Start with %PDF | 25 50 44 46 | |
| ZIP | Start with PK | 50 4B |
| GIF | Start with GIF89a | 47 49 46 38 39 61 |
Using a File Format Detector
- Upload any file
- The tool reads the first bytes of the file
- It matches against known file signatures
- Returns the true file type, MIME type, and whether the extension matches
When This Is Useful
- Received a file that will not open — check if the extension is correct
- Security check — verify downloaded files are what they claim to be
- Debugging — determine why a file is not being accepted by a service
- Recovery — identify files that lost their extensions
file formatfile detectionmagic bytesmime type
Try these tools