File signature checker
Find out what a file really is from its first bytes, whatever its name says. Choose a file or paste hex: the magic number is highlighted in a hex dump and checked against the extension.
The first bytes are enough for most formats. Spaces, commas, colons, new lines and 0x or \x prefixes are all fine.
Mismatch: This .jpg file is actually a PNG image. Its usual extension is .png.
- 1 × 1 pixels
- 8-bit greyscale
Why these bytes. Every PNG starts with the same eight bytes, and most of them were chosen to catch a way files used to be damaged in transit: the high bit of 89 for 7-bit channels, CR LF and LF for line-ending conversion, and 1A to stop DOS from typing it to the screen. Chunks follow, the first always IHDR with the width and height.
Hex dump, signature highlighted
| Offset | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 0A | 0B | 0C | 0D | 0E | 0F | Text |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 00000000 | 89 | 50 | 4E | 47 | 0D | 0A | 1A | 0A | 00 | 00 | 00 | 0D | 49 | 48 | 44 | 52 | .PNG........IHDR |
| 00000010 | 00 | 00 | 00 | 01 | 00 | 00 | 00 | 01 | 08 | 00 | 00 | 00 | 00 | 3A | 7E | 9B | .............:~. |
| 00000020 | 55 | 00 | 00 | 00 | 0A | 49 | 44 | 41 | 54 | 78 | 9C | 63 | 68 | 00 | 00 | 00 | U....IDATx.ch... |
| 00000030 | 82 | 00 | 81 | 77 | CD | 72 | B6 | 00 | 00 | 00 | 00 | 49 | 45 | 4E | 44 | AE | ...w.r.....IEND. |
| 00000040 | 42 | 60 | 82 | B`. |
Highlighted bytes are underlined, and a small number marks where each field starts; the table below explains them, with the signature itself in bold. The Text column shows printable ASCII and a dot for anything else.
| # | Offset and bytes | Meaning |
|---|---|---|
| 1 | 0x000089 50 4E 47 0D 0A 1A 0A | PNG signature |
| 2 | 0x000800 00 00 0D | Length of the first chunk: 13 bytes |
| 3 | 0x000C49 48 44 52 | First chunk type: IHDR, the image header |
| 4 | 0x001000 00 00 01 | Width: 1 |
| 5 | 0x001400 00 00 01 | Height: 1 |
How file signatures work
Most file formats begin with a fixed run of bytes, chosen by whoever designed the format, so that a program can tell what it has been given before reading any further. Those bytes are the file signature, or magic number. The name of a file, and its extension, is just a label: it is not stored in the file, and renaming a file changes nothing inside it.
- Usually at offset 0. PNG, JPEG, GIF, PDF, ZIP, ELF and most others start at the very first byte.
- Sometimes further in. A tar archive's ustar sits at byte 257, DICOM's DICM at byte 128, after a free preamble, and an ISO 9660 disc image's CD001 at byte 32,769 (0x8001), after 32 KB the format leaves for boot code.
- Containers need a second look. A signature can say "ZIP" or "RIFF" or "ISO media" when what you want to know is DOCX, WebP or HEIC. The answer is a little further in: the entry names, the form type, the brand.
- Byte order shows. A magic number stored as a 32-bit integer appears reversed on little-endian machines, which is why a 64-bit Mach-O program on an Intel or Apple silicon Mac starts CF FA ED FE rather than FE ED FA CF.
- Text has none. CSV, JSON, Markdown and source code are just characters. A byte order mark or a telling start such as <?xml or #! is as close as text gets.
The Unix file command works this way, from a database of these patterns; this page's tests check its answers against it. To read the bytes yourself, the ASCII table gives the letters behind the hex and hex to binary shows the bits.
Why PNG starts with 89 50 4E 47 0D 0A 1A 0A
PNG's eight bytes were chosen with care. Apart from the three letters of the name, each one catches a way that files used to get damaged when they were copied between systems, so a broken PNG is spotted in its first eight bytes instead of half way through decoding.
| Bytes | Hex and text | Why it is there |
|---|---|---|
| 0 | 89(none) | Has the top bit set, so a channel that only carries 7 bits damages it, and the file cannot be mistaken for text. |
| 1 to 3 | 50 4E 47PNG | The name in ASCII, so a person can recognise the format in a text editor or a hex dump. These three catch no damage. |
| 4 to 5 | 0D 0ACR LF | A DOS line ending: a transfer that turns CR LF into LF breaks the signature. |
| 6 | 1A^Z | Ctrl+Z, the end-of-file marker for text under DOS: typing the file on a DOS console stops here instead of printing binary. |
| 7 | 0ALF | A lone line feed: a transfer that turns LF into CR LF breaks the signature. |
One signature, many formats
Several popular formats are containers with agreed contents, so their first bytes say only what the container is. ZIP archives start 50 4B 03 04 (PK, after Phil Katz of PKZIP), and these formats are all ZIP archives underneath:
| Format | How the checker tells it apart |
|---|---|
| EPUB e-book.epub | First entry is an uncompressed file called mimetype holding application/epub+zip |
| OpenDocument text (ODT).odt | Stored mimetype entry first: application/vnd.oasis.opendocument.text |
| OpenDocument spreadsheet (ODS).ods | Stored mimetype entry first: application/vnd.oasis.opendocument.spreadsheet |
| OpenDocument presentation (ODP).odp | Stored mimetype entry first: application/vnd.oasis.opendocument.presentation |
| OpenDocument drawing (ODG).odg | Stored mimetype entry first: application/vnd.oasis.opendocument.graphics |
| Android app (APK).apk | Has AndroidManifest.xml at the top level (and usually classes.dex) |
| Word document (DOCX).docx, .docm, .dotx | Has [Content_Types].xml and a word/ folder |
| Excel workbook (XLSX).xlsx, .xlsm, .xltx | Has [Content_Types].xml and an xl/ folder |
| PowerPoint presentation (PPTX).pptx, .pptm, .potx | Has [Content_Types].xml and a ppt/ folder |
| Office Open XML document (DOCX, XLSX or PPTX).docx, .xlsx, .pptx | Has [Content_Types].xml, but the entries read so far do not show which Office format |
| Java archive (JAR).jar | Has META-INF/MANIFEST.MF (an APK has one too, so APK is checked first) |
The ISO base media format behind MP4 is a tree of boxes, and the first is ftyp at byte 4. Its brand, a four-character code at byte 8, names the format:
| Brands | Format | Extensions |
|---|---|---|
| heic, heix, heim, heis, hevc, hevx | HEIC image (HEIF with HEVC) | .heic, .heif |
| avif, avis | AVIF image | .avif |
| mif1, msf1 | HEIF image | .heif, .heic |
| qt | QuickTime movie | .mov, .qt |
| M4A, M4B, M4P | MPEG-4 audio (M4A) | .m4a, .m4b, .m4p |
| M4V, M4VH, M4VP | MPEG-4 video (M4V) | .m4v |
| 3gp4, 3gp5, 3gp6, 3gp7, 3ge6, 3gg6 | 3GPP video | .3gp |
| 3g2a, 3g2b, 3g2c | 3GPP2 video | .3g2 |
| crx | Canon CR3 raw image | .cr3 |
| isom, iso2, iso4, iso5, iso6, mp41, mp42, avc1, dash, mmp4, MSNV, f4v | MP4 video | .mp4, .m4v, .f4v |
RIFF works the same way for WebP, WAV and AVI: RIFF, a 4-byte size, then the form type WEBP, WAVE or AVI followed by a space, since a form type is always four characters.
CAFEBABE: Java class or Mach-O?
Two unrelated formats start with the same four bytes, CA FE BA BE. The next four bytes settle it. Here are the first eight bytes of a real class file, compiled by javac, and of a real macOS universal binary, made by lipo:
Java class file
CA FE BA BE 00 00 00 41
After the magic come two 16-bit numbers, the minor and major version: 00 00 is 0 and 00 41 is 65. Class file version 65.0: Java 21.
Mach-O universal binary
CA FE BA BE 00 00 00 02
After the magic comes one 32-bit number, the count of architectures inside: 2 architectures: x86-64, arm64. No Java release has a major version that small; the first, Java 1.0, used 45.
Famous magic numbers
Some magic numbers are chosen to be readable as words in hex, which makes them easy to spot in a dump. The same number looks different in memory depending on byte order:
CAFEBABE
- Big-endian bytes
- CA FE BA BE
- Little-endian bytes
- BE BA FE CA
The first four bytes of every compiled Java class file, and of a Mach-O universal binary on macOS (one file holding the same program for several processors).
FEEDFACE
- Big-endian bytes
- FE ED FA CE
- Little-endian bytes
- CE FA ED FE
The magic number of a 32-bit Mach-O file, the executable format of macOS and iOS, as used on PowerPC and older Intel Macs and on older iPhones. It is stored in the processor's byte order, so a 32-bit file from an Intel Mac starts CE FA ED FE, and one from a PowerPC Mac FE ED FA CE.
FEEDFACF
- Big-endian bytes
- FE ED FA CF
- Little-endian bytes
- CF FA ED FE
The 64-bit Mach-O magic number, FEEDFACE plus one, and the one on every current Mac program: Intel and Apple silicon Macs are little-endian, so a single-architecture file, or each slice of a universal one, starts CF FA ED FE.
DEADBEEF
- Big-endian bytes
- DE AD BE EF
- Little-endian bytes
- EF BE AD DE
Not a file signature. It is a value written into memory on purpose, so that reading uninitialised or freed memory stands out in a debugger or a crash dump. It is a well known piece of hexspeak, words spelled with the letters A to F.
File signature table
Every signature the checker knows, 70 of them, generated from the same data the checker uses. With the ZIP and ISO media kinds above and the text formats, it names 86 formats in all. ?? is a byte that can be anything.
| Format | Bytes | Offset | Extensions | As text |
|---|---|---|---|---|
| Images | ||||
| PNG image | 89 50 4E 47 0D 0A 1A 0A | 0 | .png | .PNG.... |
| JPEG image | FF D8 FF | 0 | .jpg, .jpeg, .jfif, .jpe | ... |
| GIF image | 47 49 46 38 37 61 | 0 | .gif | GIF87a |
| GIF image | 47 49 46 38 39 61 | 0 | .gif | GIF89a |
| WebP image | 52 49 46 46 ?? ?? ?? ?? 57 45 42 50 | 0 | .webp | RIFF....WEBP |
| BMP image | 42 4D | 0 | .bmp, .dib | BM |
| TIFF imagelittle-endian | 49 49 2A 00 | 0 | .tif, .tiff | II*. |
| TIFF imagebig-endian | 4D 4D 00 2A | 0 | .tif, .tiff | MM.* |
| TIFF imageBigTIFF | 49 49 2B 00 | 0 | .tif, .tiff | II+. |
| TIFF imageBigTIFF | 4D 4D 00 2B | 0 | .tif, .tiff | MM.+ |
| Windows icon (ICO) | 00 00 01 00 | 0 | .ico | .... |
| Windows icon (ICO) | 00 00 02 00 | 0 | .ico | .... |
| Photoshop document (PSD) | 38 42 50 53 00 01 | 0 | .psd | 8BPS.. |
| Photoshop document (PSD) | 38 42 50 53 00 02 | 0 | .psd | 8BPS.. |
| DICOM medical image | 44 49 43 4D | 128 | .dcm, .dicom | DICM |
| Audio | ||||
| MP3 audioOr a frame sync, FF Fx or FF Ex, with no tag | 49 44 33 | 0 | .mp3 | ID3 |
| WAV audio | 52 49 46 46 ?? ?? ?? ?? 57 41 56 45 | 0 | .wav | RIFF....WAVE |
| AIFF audio | 46 4F 52 4D ?? ?? ?? ?? 41 49 46 46 | 0 | .aiff, .aif, .aifc | FORM....AIFF |
| AIFF audio | 46 4F 52 4D ?? ?? ?? ?? 41 49 46 43 | 0 | .aiff, .aif, .aifc | FORM....AIFC |
| FLAC audio | 66 4C 61 43 | 0 | .flac | fLaC |
| Ogg media | 4F 67 67 53 00 | 0 | .ogg, .oga, .ogv, .opus | OggS. |
| MIDI file | 4D 54 68 64 00 00 00 06 | 0 | .mid, .midi | MThd.... |
| Video | ||||
| AVI video | 52 49 46 46 ?? ?? ?? ?? 41 56 49 20 | 0 | .avi | RIFF....AVI |
| Matroska video | 1A 45 DF A3 | 0 | .mkv, .mka, .mks, .mk3d | .E.. |
| MP4, MOV, M4A, HEIC, AVIFBytes 0 to 3 are the box size; the brand at 8 decides MP4, MOV, M4A, HEIC or AVIF | 66 74 79 70 | 4 | .mp4, .mov, .m4a, .heic | ftyp |
| QuickTime movie (no ftyp box)Older QuickTime files open with another box instead of ftyp | 6D 6F 6F 76 | 4 | .mov, .qt | moov |
| QuickTime movie (no ftyp box) | 6D 64 61 74 | 4 | .mov, .qt | mdat |
| QuickTime movie (no ftyp box) | 77 69 64 65 | 4 | .mov, .qt | wide |
| QuickTime movie (no ftyp box) | 66 72 65 65 | 4 | .mov, .qt | free |
| Archives and compression | ||||
| ZIP archive | 50 4B 03 04 | 0 | .zip | PK.. |
| ZIP archiveempty | 50 4B 05 06 | 0 | .zip | PK.. |
| ZIP archivesplit | 50 4B 07 08 | 0 | .zip | PK.. |
| gzip compressed file | 1F 8B 08 | 0 | .gz, .tgz | ... |
| bzip2 compressed file | 42 5A 68 | 0 | .bz2, .tbz2, .tbz | BZh |
| XZ compressed file | FD 37 7A 58 5A 00 | 0 | .xz, .txz | .7zXZ. |
| 7-Zip archive | 37 7A BC AF 27 1C | 0 | .7z | 7z..'. |
| RAR archiveRAR 5 | 52 61 72 21 1A 07 01 00 | 0 | .rar | Rar!.... |
| RAR archiveRAR 4 | 52 61 72 21 1A 07 00 | 0 | .rar | Rar!... |
| tar archivePOSIX | 75 73 74 61 72 00 30 30 | 257 | .tar | ustar.00 |
| tar archiveGNU | 75 73 74 61 72 20 20 00 | 257 | .tar | ustar . |
| Zstandard compressed file | 28 B5 2F FD | 0 | .zst | (./. |
| LZ4 compressed file | 04 22 4D 18 | 0 | .lz4 | ."M. |
| Documents | ||||
| PDF documentReaders accept it anywhere in the first 1024 bytes | 25 50 44 46 2D | 0 | %PDF- | |
| Microsoft compound file (old Office, MSI) | D0 CF 11 E0 A1 B1 1A E1 | 0 | .doc, .xls, .ppt, .msi | ........ |
| Rich Text Format document | 7B 5C 72 74 66 | 0 | .rtf | {\rtf |
| PostScript document | 25 21 50 53 | 0 | .ps, .eps | %!PS |
| Encapsulated PostScript with a preview (DOS EPS) | C5 D0 D3 C6 | 0 | .eps | .... |
| Programs and code | ||||
| ELF executable | 7F 45 4C 46 | 0 | .elf, .so, .o, .ko | .ELF |
| Windows executable (PE) | 4D 5A | 0 | .exe | MZ |
| Mach-O binary64-bit, little-endian | CF FA ED FE | 0 | .dylib, .o, .bundle | .... |
| Mach-O binary32-bit, little-endian | CE FA ED FE | 0 | .dylib, .o, .bundle | .... |
| Mach-O binary64-bit, big-endian | FE ED FA CF | 0 | .dylib, .o, .bundle | .... |
| Mach-O binary32-bit, big-endian | FE ED FA CE | 0 | .dylib, .o, .bundle | .... |
| Java class file or Mach-O universal binaryShared by Java class files and Mach-O universal binaries; the next four bytes decide | CA FE BA BE | 0 | .class | .... |
| Mach-O universal binary, 64-bit | CA FE BA BF | 0 | none | .... |
| Android Dalvik executable (DEX) | 64 65 78 0A ?? ?? ?? 00 | 0 | .dex | dex..... |
| WebAssembly module | 00 61 73 6D | 0 | .wasm | .asm |
| Fonts | ||||
| WOFF web font | 77 4F 46 46 | 0 | .woff | wOFF |
| WOFF2 web font | 77 4F 46 32 | 0 | .woff2 | wOF2 |
| TrueType font | 00 01 00 00 | 0 | .ttf | .... |
| TrueType font | 74 72 75 65 | 0 | .ttf | true |
| OpenType font (CFF) | 4F 54 54 4F | 0 | .otf | OTTO |
| TrueType font collection | 74 74 63 66 | 0 | .ttc, .otc | ttcf |
| Data and disk images | ||||
| SQLite database | 53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00 | 0 | .sqlite, .sqlite3, .db, .db3 | SQLite format 3. |
| ISO 9660 disc image | 43 44 30 30 31 | 0x8001 | .iso | CD001 |
| Text | ||||
| UTF-8 text with a byte order mark | EF BB BF | 0 | .txt | ... |
| UTF-32 text, little-endian | FF FE 00 00 | 0 | .txt | .... |
| UTF-32 text, big-endian | 00 00 FE FF | 0 | .txt | .... |
| UTF-16 text, little-endian | FF FE | 0 | .txt | .. |
| UTF-16 text, big-endian | FE FF | 0 | .txt | .. |
Common mistakes
- Renaming to convert. Changing .png to .jpg makes a PNG with the wrong name, not a JPEG. Most image viewers still open it, which hides the problem until something stricter does not.
- An error page saved as the file. A download link that fails often hands back an HTML error page under the name you asked for, so "logo.png" turns out to be <!DOCTYPE html>. Try the example.
- Reading a little-endian magic number backwards. Zstandard's magic number is FD2FB528 but its files start 28 B5 2F FD, because it is stored low byte first.
- Treating "ZIP" as the whole answer. An Office document, an e-book and an Android app are all ZIP archives; the contents say which.
- Trusting a signature for safety. A valid header says how a file starts, not what the rest does. Files can be valid in two formats at once.
Questions
What is a file signature?
A fixed run of bytes, usually at the very start of a file, that marks its format. PNG files start 89 50 4E 47 0D 0A 1A 0A, PDFs start %PDF-, and ZIP archives start PK. They are also called magic numbers. Programs use them to tell a file’s real type, because the extension in its name is only a label that anyone can change.
Can I convert a file by renaming it?
No. Renaming changes the label, not the bytes: a PNG renamed to .jpg is still a PNG, and this checker will say "This .jpg file is actually a PNG image. Its usual extension is .png." Many programs open it anyway because they look at the signature, but upload forms that only accept certain extensions may reject or mishandle it. To change the format, open it in an editor or converter and save it as the new type.
Is my file uploaded anywhere?
No. The file is read in your browser with the File API: the first 36 KB and the last 64 KB, which reaches every signature here, including ISO 9660 at byte 32,769, and a ZIP's end record. When a big ZIP's central directory starts further back, it is read from there to the end, up to 16 MB. Nothing is sent to a server, and a chosen file never goes into the page's link.
Why does my DOCX show up as a ZIP file?
Because it is one. DOCX, XLSX, PPTX, EPUB, OpenDocument, JAR and APK files are all ZIP archives with agreed contents, so they all start PK 03 04. The checker looks inside, at the entry names (a word/ folder for DOCX) or a stored mimetype entry (EPUB and OpenDocument), to say which. It knows 11 of these.
Why can it not tell what my CSV or text file is?
Text has no signature. A CSV, a Markdown file, source code and plain notes are all just characters, so the best any tool can do is notice that the bytes are valid text and maybe spot a telling start, like <?xml, <!DOCTYPE html or #!. Those are shown as likely or a guess, never as certain.
Does a correct signature mean a file is safe?
No. A signature only says how the file starts. Anything can follow a valid header, and some files are deliberately valid in two formats at once (polyglots). Use it to find out what a file claims to be, not to decide whether to trust it.