Published · Updated

File Signatures & Magic Bytes Guide

When you double-click a file, your operating system usually looks at the letters after the final dot—such as .pdf, .jpg or .docx—to decide which app should open it. That extension is only part of the filename. The actual format is recorded inside the file’s bytes.

Many formats begin with a fixed sequence of bytes called a file signature or magic bytes. Inspecting those bytes is the fastest way to find out what an unfamiliar or mislabelled file really is.

You can inspect a file’s signature and first 64 bytes locally in your browser with the free File Sniff file type checker.

How file signatures work

A file signature is a short marker placed at a predictable position near the beginning of a file so software can recognise the format immediately:

Common file signatures at a glance

FormatHex signatureASCII / markerOffset
PNG image (.png)89 50 4E 47 0D 0A 1A 0A.PNG....0
JPEG image (.jpg, .jpeg)FF D8 FF(binary)0
GIF image (.gif)47 49 46 38 37 61 / 47 49 46 38 39 61GIF87a / GIF89a0
WebP image (.webp)52 49 46 46 … 57 45 42 50RIFF…WEBP0 & 8
PDF document (.pdf)25 50 44 46 2D%PDF-0
ZIP / OOXML container (.zip, .docx, .xlsx, .pptx)50 4B 03 04PK..0
HEIC / MP4 / MOV (ftyp box)… 66 74 79 70…ftyp + brand4
Legacy Office / Outlook (.doc, .xls, .ppt, .msg)D0 CF 11 E0 A1 B1 1A E1(OLE Compound Document)0
Outlook TNEF (winmail.dat, .dat)78 9F 3E 22x.>"0
7-Zip archive (.7z)37 7A BC AF 27 1C7z....0
RAR archive (.rar)52 61 72 21 1A 07Rar!..0
Gzip archive (.gz, .tgz)1F 8B 08(binary)0
SQLite database (.sqlite, .db)53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00SQLite format 3\00
Windows PE executable (.exe, .dll)4D 5A … 50 45 00 00MZ … PE\0\00 & e_lfanew
Mach-O executable (macOS / iOS)CF FA ED FE / FE ED FA CF(binary)0
WebAssembly binary (.wasm)00 61 73 6D 01 00 00 00\0asm....0

When the signature only shows a container

Some magic bytes identify an outer packaging format rather than the specific document type inside:

  1. ZIP-based document formats: Microsoft Word (.docx), Excel (.xlsx), PowerPoint (.pptx), EPUB books (.epub), Android packages (.apk) and OpenDocument files all start with 50 4B 03 04 (PK\x03\x04). To tell a Word document apart from an ordinary ZIP archive without decompressing the file, a checker inspects the ZIP central directory at the end of the file for entries such as [Content_Types].xml and word/document.xml, xl/workbook.xml or ppt/presentation.xml.
  2. OLE Compound Documents: Older Office files (.doc, .xls, .ppt) and Outlook .msg emails share the same eight-byte OLE header (D0 CF 11 E0 A1 B1 1A E1). Distinguishing them requires reading the internal OLE directory streams.
  3. Plain text formats: Files such as .txt, .csv, .json, .md or scripts do not have a mandatory binary header. A careful checker validates UTF-8 text and syntax (such as complete JSON or a #! shebang) rather than guessing from a filename.

What magic bytes cannot prove

File signatures are designed for format recognition, not security verification:

Try inspecting a file with the free file type checker, learn how to identify an unknown file, or read what a file extension mismatch means.