File Type Detector (Magic Bytes)
Drop a file to identify its true format from its magic bytes — and catch files whose extension or declared MIME type lies.
How to use
- Drop or pick any file.
- Read the detected type — if it disagrees with the declared one, the badge will tell you.
- Copy the detected MIME type to use in a Content-Type header or an upload allow-list.
About this tool
ShowHide
Drop a file and the first 512 bytes are read in the browser and matched against a table of about thirty-five signatures — PNG, JPEG, GIF, WebP, TIFF, PDF, ZIP, GZIP, XZ, 7z, RAR, TAR, MP3, FLAC, WAV, OGG, MP4, MKV, WOFF2, ELF, PE, SQLite and others. The detected type is then compared against the MIME type the browser reported, which the operating system almost always derived from the extension, and any disagreement is flagged. A declared type built on the detected container — a DOCX against ZIP, WebM against Matroska, MOV or M4A against MP4 — counts as a match rather than a mismatch.
Signatures are not always at the start, and the table accounts for that. A TAR archive has nothing identifiable in its first bytes at all — its ustar marker sits at offset 257, inside the first file's header block. RIFF containers put four bytes of length between the magic and the form type, so WAV and WebP both read as RIFF????WAVE and RIFF????WEBP with wildcards in the middle. PNG's eight-byte signature is worth a look for its own sake: the leading 0x89 fails immediately if something stripped the high bit, the \r\n and the trailing \n detect line-ending translation by a transfer in text mode, and the 0x1A in the middle is a DOS end-of-file so that printing the file to a terminal stops rather than scrolling forever. Every byte in it is a specific test.
The honest limit is containers. DOCX, XLSX, PPTX, ODT, EPUB, JAR and APK are all ZIP archives, so they all begin PK\x03\x04 and magic bytes alone cannot tell them apart — you have to open the archive and look at what is inside. Plain-text formats have no signature to find: CSV, JSON, HTML, SVG and source code are all just text, and a detector that reports nothing for them is correct rather than broken.
Knowing the real type is not the same as knowing a file is safe. A file can be a genuine, valid PNG and still be crafted to exploit a bug in whatever decodes it, and polyglot files — valid as two formats at once — have been used to slip past exactly this kind of check. Use the result to catch a mislabelled download or a renamed extension, and keep whatever validation the consuming code already does. Nothing is uploaded; the read happens on your machine.
Frequently asked questions
Does the file leave my browser?
No. Only the first 512 bytes are read, and only locally through the File API. Nothing is uploaded.
Why does a .docx come up as ZIP?
DOCX, XLSX, PPTX, JAR, EPUB, and OOXML are all ZIP containers under the hood. To distinguish them you'd need to inspect a specific entry inside the archive — magic-byte detection alone can't tell them apart.
The signature matches, but the file still will not open. Why?
Magic bytes only describe the beginning of a file. A download that was cut short, a binary transferred in text mode (which rewrites line endings inside the data), or a container whose payload is corrupt all keep a perfectly valid header while the rest is unusable. Detection tells you what a file claims to be, not that it is complete.
Can two formats share one signature?
Yes, and ZIP is the clearest case: .docx, .xlsx, .odt, .jar, .apk and .epub are all ZIP archives, so their real identity is decided by what sits inside rather than by the first bytes. Some formats are also identified by bytes further into the file, which is why a very short file, or one wrapped in another container, can come back unidentified.
Guides on this topic
Related tools
MIME Type Lookup
Find the MIME type for a file extension (or the other way around) and learn what each type is for.
Developer
EML File Viewer
Drop an .eml file and read the parsed message — key headers, plain-text and HTML body parts, and a list of attachments — all in the browser.
File
Mbox Archive Viewer
Split a .mbox archive in your browser: message boundaries, decoded headers, MIME structure, threads and duplicate Message-IDs. Nothing is uploaded.
File
File Encoding Detector
Upload any text file and detect its encoding — UTF-8, UTF-16 LE/BE, UTF-32, Latin-1, ASCII — with BOM detection, byte signal analysis, and a hex preview.
File
Python .pyc Bytecode Inspector
Open a .pyc from __pycache__ in your browser: which CPython wrote it, timestamp or hash invalidation, the code object tree and the disassembly.
Developer
Byte Size Converter (KB / KiB / MB / MiB / ...)
Convert between decimal (KB, MB, GB — SI base 1000) and binary (KiB, MiB, GiB — IEC base 1024) byte units, plus bits.
Convert