Settings

The file

Drop a file here to read its signature, or

Drop any file. Only the first kilobyte is read, in the tab.

How it works

Why the name can lie

Renaming secret.exe to holiday.jpg does not change a single byte inside it: it still begins with MZ, the Windows executable signature, and it is still a program to anything that reads its bytes rather than its name. The extension is a hint for the desktop, not a fact about the file. Every program that opens a file reads the signature instead, and so does MAGIC: it tells you what the bytes are, and when the name on the file disagrees with them.

Questions people ask about MAGIC

What is a magic number in a file?

A fixed run of bytes, usually at the very start, that a format puts there so a program can recognise it without trusting the name. A PDF begins %PDF-, a JPEG FF D8 FF, a zip 50 4B 03 04 (the letters PK), and a PNG 89 50 4E 47 0D 0A 1A 0A, whose carriage return and line feed are there to show if a transfer has rewritten line endings.

Not every signature is at offset 0. A tar archive has ustar at byte 257, and an MP4 has ftyp at byte 4. MAGIC checks each at its own offset and shows the first 16 bytes in hex and ASCII so you can see what it saw.

Which formats does it recognise?

Images (PNG, JPEG, GIF, WebP, BMP, TIFF, ICO, Photoshop, AVIF, HEIF and HEIC); PDF, RTF and PostScript; the Office 97-2003 and Outlook compound file (.doc, .xls, .ppt, .msg); archives (gzip, bzip2, xz, Zstandard, 7-Zip, RAR, tar, zip, EPUB, OpenDocument); programs (Windows PE, ELF, Mach-O, Java class, WebAssembly, and scripts starting #!, named by the interpreter on that line: Python, Node.js, Perl, Ruby, PHP or a shell); memory and crash dumps (Windows minidump and kernel dump, LiME, makedumpfile, hibernation files, ELF and Mach-O core files); SQLite; pcap and pcapng captures; audio and video (MP3, FLAC, Ogg, WAV, AVI, MIDI, Matroska and WebM, MP4 and QuickTime); and text with a byte order mark.

Each result gives the format’s name, its media type and its usual extensions. The first signature that matches wins, and more specific ones are checked before the containers they sit in.

Why does a .docx show as a ZIP archive?

Because it is one. Word, Excel and PowerPoint files, Java .jar files and Android .apk files are all zip archives and share its signature, so MAGIC names the zip and counts any of those extensions as a match. It does not look inside to tell a .docx from a .xlsx.

EPUB and OpenDocument files are named as such when their first entry is an uncompressed file called mimetype, which both formats require. If a .docx opens as a page of XML, see why a .docx opens as XML.

Why does a text, HTML or CSV file come back unrecognised?

Plain text has no magic number. HTML, XML, JSON, CSV and source code all start with whatever their author wrote, so there is no fixed byte sequence to match. The only text MAGIC recognises is text that starts with a byte order mark, which names UTF-8, UTF-16 little-endian or UTF-16 big-endian.

In every case the first bytes are shown, which is often enough to tell by eye.

Can a file have the right signature and still be something else?

Yes. A signature only says how a file begins. Some are short: MZ (a Windows program) and #! (a script) can open an ordinary text file by chance. BM is checked further, against a bitmap’s reserved bytes and header size, so text that starts with those letters is not called a bitmap.

Some signatures are shared. CA FE BA BE begins both a Java class and a multi-architecture Mach-O program, and MAGIC names both. An ftyp box begins MP4, QuickTime, HEIF and AVIF alike; HEIC and AVIF are told apart by their brand, and a brand MAGIC does not list is reported as MP4. The Office 97-2003 compound file is one signature for .doc, .xls, .ppt and .msg, so MAGIC names the family and counts any of them as a match.

Should I worry when it says the extension does not match?

A mismatch is a fact, not a verdict. Often it is harmless: a picture saved from a website as .jpg that is really WebP or PNG, or a file renamed by hand. A program’s signature (Windows PE, ELF or Mach-O) under the name of a photo or a document is different, because there is no innocent reason for it.

A file with no extension is reported with what its bytes are and nothing to compare. An extension made only of digits, such as core.3141, is treated as no extension, since tools that write dumps put a process ID or a date there.

Does it check that the whole file is valid?

No. It reads the first kilobyte and nothing more, which is why a large file is identified as quickly as a small one. A file cut short, or damaged after its first kilobyte, still shows its correct type here. To look further in, open it in HEX, whose structure pane reads a format’s headers and the end of the file.

Doing this often? The Sovereign Console loads whole sets of files as evidence, identifies and fingerprints each, and opens every one in the tool made for it. On its own, US$2 a month; with everything else, US$5 a month or US$48 a year.