FreeToGenerate.com

A file says what it is in its first few bytes. Some formats fix those bytes in a standard; several never wrote them down at all. Nothing is uploaded.

Identify a file

Drop a file here, or choose one.

Only the first bytes are read, and they are read in your browser. The file is not uploaded and never leaves your machine.

standard
15
informational
1
vendor doc
14
convention only
3
33 / 33
PNGstandard.pngimage/png
89 50 4E 47 0D 0A 1A 0A·PNG····At byte 0 (the start)

Written down in: ISO/IEC 15948 §5.2

The current standard states these eight bytes and does not say why. The explanation — a non-ASCII first byte so a transfer that clears the high bit is caught, a CR-LF to catch newline translation, a control-Z to stop MS-DOS listing the file, and a final line feed for the inverse problem — survives only in the informational RFC the standard replaced.

JPEGstandard.jpg .jpegimage/jpeg
FF D8 FF···At byte 0 (the start)

Written down in: ITU-T T.81 §B.1 (SOI marker)

Only the first bytes are fixed. What follows varies with the encoder, which is why this signature is shorter than most.

GIF 87avendor doc.gifimage/gif
47 49 46 38 37 61GIF87aAt byte 0 (the start)

Written down in: GIF 87a, Header block

Two versions of the format share a prefix, so the version is part of the signature rather than something read afterwards.

GIF 89avendor doc.gifimage/gif
47 49 46 38 39 61GIF89aAt byte 0 (the start)

Written down in: GIF 89a §17 (Header)

Two versions of the format share a prefix, so the version is part of the signature rather than something read afterwards.

BMPvendor doc.bmp .dibimage/bmp
42 4DBMAt byte 0 (the start)

Written down in: Microsoft BITMAPFILEHEADER (bfType)

WebPstandard.webpimage/webp
52 49 46 46RIFFAt byte 0 (the start)

Written down in: RFC 9649 §2 (RIFF container)

RIFF is a container, not a format. WebP, WAV and AVI are byte-identical here; the four bytes that distinguish them come later.

TIFF (little-endian)vendor doc.tif .tiffimage/tiff
49 49 2A 00II*·At byte 0 (the start)

Written down in: TIFF 6.0 §2 (Image File Header)

TIFF (big-endian)vendor doc.tif .tiffimage/tiff
4D 4D 00 2AMM·*At byte 0 (the start)

Written down in: TIFF 6.0 §2 (Image File Header)

ICOconvention only.icoimage/vnd.microsoft.icon
00 00 01 00····At byte 0 (the start)

Written down in: nothing normative

Photoshopvendor doc.psdimage/vnd.adobe.photoshop
38 42 50 538BPSAt byte 0 (the start)

Written down in: Adobe Photoshop File Formats, File Header

PDFstandard.pdfapplication/pdf
25 50 44 46 2D%PDF-At byte 0 (the start)

Written down in: ISO 32000-2 §7.5.2 (File header)

The signature is readable text rather than binary, which is why these files often survive being opened in a text editor.

RTFvendor doc.rtfapplication/rtf
7B 5C 72 74 66{\rtfAt byte 0 (the start)

Written down in: Microsoft RTF Specification

The signature is readable text rather than binary, which is why these files often survive being opened in a text editor.

ZIPvendor doc.zipapplication/zip
50 4B 03 04PK··At byte 0 (the start)

Written down in: PKWARE APPNOTE §4.3.7 (local file header)

A .docx, .xlsx, .jar, .apk and .epub are all ZIP archives and all carry these bytes. Telling them apart means opening the archive and looking at what is inside.

gzipstandard.gzapplication/gzip
1F 8B··At byte 0 (the start)

Written down in: RFC 1952 §2.3.1 (ID1, ID2)

bzip2convention only.bz2application/x-bzip2
42 5A 68BZhAt byte 0 (the start)

Written down in: nothing normative

XZvendor doc.xzapplication/x-xz
FD 37 7A 58 5A 00·7zXZ·At byte 0 (the start)

Written down in: The .xz File Format §2.1.1.1 (Header Magic Bytes)

7-Zipconvention only.7zapplication/x-7z-compressed
37 7A BC AF 27 1C7z··'·At byte 0 (the start)

Written down in: nothing normative

RAR 5vendor doc.rarapplication/vnd.rar
52 61 72 21 1A 07 01 00Rar!····At byte 0 (the start)

Written down in: RAR archive format documentation

tar (ustar)standard.tarapplication/x-tar
75 73 74 61 72ustarAt byte 257

Written down in: POSIX.1-2017 (ustar Interchange Format)

This one does not start at the beginning of the file, so anything that reads only the first few bytes will miss it entirely.

ISO 9660standard.isoapplication/x-iso9660-image
43 44 30 30 31CD001At byte 32769

Written down in: ECMA-119 §8.4.1 (Standard Identifier)

This one does not start at the beginning of the file, so anything that reads only the first few bytes will miss it entirely.

WAVvendor doc.wavaudio/vnd.wave
52 49 46 46RIFFAt byte 0 (the start)

Written down in: RFC 2361 / Microsoft RIFF

RIFF is a container, not a format. WebP, WAV and AVI are byte-identical here; the four bytes that distinguish them come later.

AVIvendor doc.avivideo/vnd.avi
52 49 46 46RIFFAt byte 0 (the start)

Written down in: Microsoft RIFF (AVI form)

RIFF is a container, not a format. WebP, WAV and AVI are byte-identical here; the four bytes that distinguish them come later.

MP4 / ISO base mediastandard.mp4 .m4a .movvideo/mp4
66 74 79 70ftypAt byte 4

Written down in: ISO/IEC 14496-12 §4.3 (File Type Box)

This one does not start at the beginning of the file, so anything that reads only the first few bytes will miss it entirely.

Oggstandard.ogg .oga .ogvapplication/ogg
4F 67 67 53OggSAt byte 0 (the start)

Written down in: RFC 3533 §6 (capture_pattern)

FLACstandard.flacaudio/flac
66 4C 61 43fLaCAt byte 0 (the start)

Written down in: RFC 9639 §8.1 (stream marker)

MP3 with ID3v2informational.mp3audio/mpeg
49 44 33ID3At byte 0 (the start)

Written down in: ID3v2 informal standard §3.1

Matroska / WebMstandard.mkv .webmvideo/x-matroska
1A 45 DF A3·E··At byte 0 (the start)

Written down in: RFC 8794 §4 (EBML magic)

Two versions of the format share a prefix, so the version is part of the signature rather than something read afterwards.

ELFstandardapplication/x-executable
7F 45 4C 46·ELFAt byte 0 (the start)

Written down in: System V ABI, ELF header (EI_MAG0..3)

DOS / Windows executablevendor doc.exe .dllapplication/vnd.microsoft.portable-executable
4D 5AMZAt byte 0 (the start)

Written down in: Microsoft PE Format (IMAGE_DOS_HEADER)

Java classstandard.classapplication/java-vm
CA FE BA BE····At byte 0 (the start)

Written down in: Java Virtual Machine Specification §4.1 (magic)

SQLite databasevendor doc.sqlite .dbapplication/vnd.sqlite3
53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00SQLite format 3·At byte 0 (the start)

Written down in: SQLite Database File Format §1.3 (header string)

WOFFstandard.wofffont/woff
77 4F 46 46wOFFAt byte 0 (the start)

Written down in: WOFF File Format 1.0 §3 (signature)

WOFF2standard.woff2font/woff2
77 4F 46 32wOF2At byte 0 (the start)

Written down in: WOFF File Format 2.0 §3 (signature)

Where these are specified

standardFixed in the normative text of a published standard. Change it and the file stops conforming.

informationalWritten down, but in a document that does not impose requirements — an informational RFC, or a specification that has since been superseded.

vendor docDocumented by whoever owns the format rather than by a standards body. Reliable in practice, and revisable without anyone's agreement.

convention onlyEvery tool implements it and no document requires it. These bytes are load-bearing purely because everyone agrees they are.

Every row is checked against a file a real encoder produced, so the bytes below are not transcribed from another table.

Also available in: Español · Português · Français · العربية

File signatures

The magic numbers for 33 formats, each with the document that actually defines it — and a file-drop that reads only the head, in your browser.

What is a file signature?

A file signature, or magic number, is a short fixed sequence of bytes at the start of a file that says what kind of file it is. Every PNG begins with the same eight bytes; every gzip archive begins with the same two. Programs read them because the file name is not evidence — renaming a spreadsheet to .png changes nothing about what is inside it, and a file arriving from the internet has whatever name the sender chose.

The list below has 33 formats with their bytes, where in the file those bytes sit, and the media type where one is registered. What it also has, and what tables copied from one another leave out, is the document that defines each signature. That column turns out to be the interesting one.

Because the answer is not uniform. Some signatures are fixed in the normative text of a published standard. Some are only in a vendor's own documentation. Some are in a document that no longer carries any weight. And a few — ICO, bzip2, 7-Zip — are implemented identically by every tool on earth and were never written down as a requirement anywhere.

How to use it

  1. Drop a file in, or choose one. Only the head of the file is read, and it is read by your browser. Nothing is uploaded. If a signature matches you get the format, the bytes that matched, and where they are defined.
  2. Or paste the bytes you already have. If you are looking at a hex dump, paste the first few bytes instead. Spaces, 0x prefixes and lowercase are all accepted; the tool just needs an even number of hex digits.
  3. Search the list by anything on the row. A format name, an extension, a media type, a hex prefix or the name of a specification all work. Typing png puts PNG first rather than burying it under everything that happens to contain those letters.

The PNG signature, and the explanation the standard dropped

PNG is the format worth looking at closely, because its eight bytes are the most carefully designed in the list and the story of them is not what you would expect. They are 137, 80, 78, 71, 13, 10, 26, 10 — or in text, a byte with the high bit set, then PNG, then a carriage return, a line feed, a control-Z and a final line feed.

Every one of those is doing a job. The first byte is deliberately not an ASCII character, so a text file is unlikely to be mistaken for a PNG — and, more usefully, so that a file transfer which strips the high bit from every byte is caught immediately. The carriage return and line feed catch the opposite problem: a transfer that helpfully converts line endings between platforms will mangle that pair, and the file fails at byte five instead of somewhere deep inside the image. The control-Z stops MS-DOS dumping the rest of a binary file to the terminal when someone types it. The final line feed catches the inverse of the CR-LF translation.

Here is the part that surprised us. That explanation is not in the current standard. ISO/IEC 15948, which is what standardises PNG today, states the eight bytes and moves on, keeping a single sentence in its rationale clause to the effect that the signature detects common transmission errors. The byte-by-byte reasoning survives only in RFC 2083 from 1997 — a document marked Informational, which the standard has since replaced. The bytes are normative. The reasons they are those bytes are not.

Honest limits

A signature says what a file claims to be, and that is the whole reason to check it — but it is also the limit. Bytes at the front of a file are cheap to fake. If you are deciding whether something is safe to open, a matching signature tells you the file is well-formed enough to have a plausible header and nothing more.

Not every signature starts at the beginning. The ustar marker that identifies a tar archive sits at byte 257, and ISO 9660's CD001 at byte 32769 — over 32 kilobytes in. Anything that reads only the first four bytes will miss both of the commonest archive and disc-image formats entirely, which is why this tool reads further.

Several formats are indistinguishable at the head, and the tool says so rather than guessing. WebP, WAV and AVI all begin with the same four bytes, because all three are RIFF containers and the bytes that separate them come later. A .docx, .xlsx, .jar, .apk and .epub are all ZIP archives and carry the ZIP signature; telling them apart means decompressing the archive and looking at what is inside, which is a different job. In both cases the tool reports every match rather than picking one.

Plenty of formats have no signature at all. CSV, plain text, most source code and SVG are just characters, and there is nothing fixed at the front to match — SVG in particular is XML, which may or may not start with a declaration. A file that matches nothing here has told you very little.

Finally, 33 formats is a selection rather than a census, and the list is bounded on purpose. The de-facto complete answer is the magic database that ships with the Unix file command, which runs to thousands of rules with conditional logic and byte arithmetic. What is on this page is the subset whose bytes could be checked against a real file this page's tests actually build, so every row here is verified rather than transcribed.

Why is it free?

Because it costs nothing to run. The list is part of the page and the identification happens in your browser: when you drop a file, only its first bytes are read, and they are read locally. Nothing is uploaded, no server sees your file, and there is no account.

The table is not copied from another table. Every row that could be built is checked against a file produced by a real encoder, and cross-checked against the file command's own identification, so a transposed digit fails the build instead of reaching the page. Where a format could not be built here, the page says so rather than quietly leaving it unverified.