Pikkola Mime, tool No. 83

The extension is a claim. The bytes are evidence.

Drop a file and this page reads its first bytes against the signatures that identify a format, then tells you whether the name agrees. It also carries the dictionary you keep looking up and the one header that decides how a browser treats the file.

48
signatures
77
dictionary entries
0
uploads

The inspection bench

What the file is, and what it calls itself

Everything starts from the first bytes on disk. A file with no extension is identified as confidently as one with three, and a file that lies about its extension is named twice.

Drop a file here

Only the first 64 KB are read, in this tab.

unknown

-

-

-

Declared
-
Sniffed type
-
Family
-
Bytes
-
Signature
-
Signatures matched
0
Every signature that fits

        

Three readings of one file

A file has a name, a set of bytes and a header. All three can disagree, and each disagreement fails in a different place.

01

Bytes before names

The signature sits at a fixed offset: eight bytes for PNG, three for JPEG, the letters ftyp at byte four for anything in the MP4 family. A file that carries the right bytes is that format, whatever the folder says.

02

One match is not certainty

A zip is also a docx, an xlsx, an apk and an epub, and the page can see the container but not the contents. When two readings are both true the slip says container and names both.

03

The header is a separate decision

The same file can be served as text/html and run, as image/svg+xml and run, or as application/octet-stream and download. The type you send is a security choice, not a description.

What is read, and what is only named

The table covers the containers that reach a web server. It is not the IANA registry, and the page says where its knowledge stops instead of pretending otherwise.

Part What this page does What it will not do
The extension Read, lowercased and compared against the dictionary Trusted: the extension is the claim under test
The first bytes Compared against 48 signatures at their fixed offsets Scanned for a signature anywhere in the file
A zip container Named as a container when the extension is docx, xlsx, epub or apk Open the archive and read what is inside
Text with no signature Decoded as UTF-8 and named as JSON, XML, HTML, SVG or plain text Guess a legacy encoding from the bytes
An unknown format Says unidentified and shows the hex Invent a type from a plausible-looking first byte
The Content-Type Built from the sniffed type, with a charset for text and a boundary for multipart Send anything: it is a line to copy, not a server

A signature proves the first bytes, not the whole file. A polyglot that opens as both a PDF and a zip passes every check on this page, and a truncated PNG passes too: the signature survives a cut at byte nine.

Field guide

Bytes, names and headers

Three things are called a file's type, and only one of them is on the disk. This is what a signature proves, where a container hides what it holds, and why the header you send is a security decision rather than a description.

What a signature proves, and what it does not

A signature is a short run of bytes at a fixed offset that a format's reader looks for first. PNG begins with 89 50 4E 47 0D 0A 1A 0A, JPEG with FF D8 FF, a PDF with the four characters %PDF, a gzip with 1F 8B 08. Formats that grew out of a container system put their marker somewhere else: the ISO base media family, which includes MP4, HEIC, AVIF and M4A, writes a size field first and puts ftyp at byte four, then a brand four bytes later. tar writes ustar at byte 257 because the first 257 bytes are a header in an older tar layout.

What that proves is that the first bytes match a format, and nothing more. A file can carry the eight bytes of a PNG and then a shell script, and some formats are explicitly designed to be two files at once: a valid PDF with a zip appended opens as both, which is called a polyglot and is a real attack technique. A signature is a good filter and a poor guarantee, which is exactly how a server should use it.

The containers that hide their contents

A zip starts PK\x03\x04, and so does every Open XML document: .docx, .xlsx, .pptx, .odt, .epub and an .apk are all zips with a particular internal layout. A reader that only looks at the first four bytes cannot tell them apart, and a reader that claims it can is lying or has opened the archive. This page names the container and lets the extension say what is inside, which is the same split a server makes when it sends application/vnd.openxmlformats-officedocument... for a file whose bytes are a zip.

The RIFF family works the other way: WebP, WAV and AVI all begin RIFF, then a length, then WEBP, WAVE or AVI  at byte eight. Looking at only the first four bytes leaves three formats indistinguishable, and looking at the second marker separates them without opening anything.

Why an extension is the weakest of the three

An extension is a string in a directory entry. It is written by whoever saved the file, changed by whoever renamed it, and dropped entirely by some upload paths. On a desktop it usually agrees with the bytes because the same program wrote both; on a download from a web application, in a message attachment, or in a folder someone else curated, it is a claim that has not been checked. The mismatch case this page exists for is not exotic: a screenshot saved as .pdf, an archive downloaded as .zip that was really a .gz, an image a build script wrote with the wrong suffix.

The header is where a type becomes behaviour

When a browser receives a file it uses the Content-Type header first, the file's extension second, and its own sniffing of the bytes third, and different browsers order those differently. That gap is the basis of a class of bugs: an upload endpoint that accepts any file and serves it from the same origin with a type taken from the extension will happily serve an HTML page as image/png, and a browser that sniffs the bytes may render it and run its script. The two fixes are old and still the right ones: send the type you actually mean, and send X-Content-Type-Options: nosniff so the browser stops second-guessing you.

SVG is the format to be careful with. It is an image, it is XML, and it can carry a script. Serving a user-supplied SVG inline as image/svg+xml runs that script in your origin. Serving the same file as application/octet-stream with a download disposition does not. The bytes are identical; the header is the whole difference.

Text, and the fallback that is honest

Plenty of formats have no signature at all: CSV, plain text, many JSON exports, a .env file. For those the page decodes the first four kilobytes as strict UTF-8 and, if that succeeds and no control characters appear, names the text by its first non-space characters: <!doctype html, <?xml, {. That is a fallback, not a signature, and the slip says so by naming the family as text rather than pretending to a certainty it does not have.

When the same bytes have to travel through a channel that only carries text, Pikkola Base64 makes the trip reversible. When what matters is whether a file is the one you meant, Pikkola Hash answers that instead.

Questions

Is my file uploaded anywhere?

No. The file is read with the browser's own file reader and the bytes never leave the tab. The only request the page makes after it loads is the cookieless page-view count, which records that the page opened and nothing about the file.

Why does a Word document come out as a zip?

Because that is what it is. A .docx is a zip archive holding XML, and its first four bytes are PK\x03\x04 exactly as a .zip's are. The slip calls it a container and names both types, which is the honest answer: this page can see the outside of the box without opening it.

Does a match prove the file is safe?

No, and it is worth being blunt about it. A file can begin with the eight bytes of a PNG and carry anything after them, and some formats are designed to be read two ways at once. A signature rules out a renamed file, not a malicious one.

Why does the header say charset only for text?

Because a charset on an image or an archive is meaningless and some clients copy it into places where it confuses them. For text, HTML, JSON, XML and SVG, a missing charset lets the browser guess from the bytes, and that guess is where mojibake and some injection bugs begin.

Can I add a type that is missing?

Not from the page, because the table is what the page is. A format worth adding is worth a message with its signature offset and a sample: hello@pikkola.com. The dictionary already carries about seventy extensions, including the ones a build script asks about.