A file extension is not a property of a file. It is part of its name — a few characters after the last dot, added by a person or a program when the file was created. The operating system uses it as a hint, and most of the time the hint is correct. When it is not, the gap between the label and the contents can waste an afternoon.
This is not an argument against extensions. It is an argument for reading them as claims rather than facts. The claim is usually honest; the problem is that nothing enforces it.
A label chosen by a person
Rename a PDF to notes.txt and the file is still a PDF. The bytes have not changed; only the name has. A PDF reader may open it anyway, because it inspects the contents; a text editor may show a page of unreadable symbols, because it trusts the label. The same file can succeed in one program and fail in another for the simple reason that the programs disagree about which evidence to believe.
On macOS, file extensions are hidden by default. On Windows, they are visible unless the “hide known file types” option is on. In both cases, the name can look simpler than it is. A document that appears to be invoice.pdf may really be invoice.pdf.exe, with the last part hidden. The label is the same; the file is very different.
What the bytes say
Most formats begin with a signature — a short sequence of bytes that identifies the family. A PDF usually starts with %PDF-; a JPEG with FF D8 FF; a PNG with a fixed eight-byte header; a ZIP archive with PK. An MP4 file carries a ftyp box near the beginning, and a WAV file starts with RIFF. These signatures are often called magic numbers, and they are the basis of content sniffing: software ignores the extension and looks at the first few bytes.
Content sniffing is not a perfect test. A file can be crafted to begin with one signature and contain something else; a container can hold formats that the signature does not describe. But for ordinary office files, the first inspection is more reliable than the name. It explains why a .docx renamed to .zip opens as an archive, and why a .jpg that is really a PNG may display correctly in a browser that sniffs the content while failing in an older application that does not.
Why programs disagree
Software has different policies. Some applications trust the extension, some trust the MIME type supplied by the operating system or a server, and some inspect the content. Browsers are deliberately forgiving because they must display whatever the web sends; office suites are more conservative; upload forms may check only the final three letters. A file that passes one gate can fail the next, not because it changed, but because the gate is asking a different question.
This is also why “the file opens on my computer” is a weak test. Your computer has your fonts, your viewers and your settings. The recipient’s machine has a different set. The extension is a shared convention, not a shared environment.
The double extension
The double extension is the oldest trick in the file-label repertoire: report.pdf.exe is an executable with a PDF-like name. If extensions are hidden, it may appear as report.pdf. The lesson is not that every file is hostile; it is that the name is a poor security boundary. Before opening an unexpected executable, look at the full name and consider the source. Before uploading a document that must be a PDF, check that it really is one.
How to check
Start by showing file extensions in your operating system. Then open the file’s information panel: most systems display the “kind” or content type alongside the name. If you need more certainty, a hex viewer or a command-line tool such as file will show the signature at the beginning of the file. On a Mac, mdls can report the content type; on Windows, PowerShell can read the first bytes. None of this requires special software for the common cases.
The simplest test is still behavioural: open the file in the application that will actually use it, on the device that will actually receive it. If it behaves, the label and the content are probably aligned. If it does not, you have found the mismatch before it becomes someone else’s problem.
The extension is still useful
None of this makes extensions useless. They help the operating system choose an application, help people recognise a file at a glance, and help a folder remain readable. They are a convention, and conventions are valuable precisely because they are not enforced by the bytes. The mistake is treating a convention as a guarantee.
A cautious reader keeps both ideas in mind: the name is a useful sign, and the content is the evidence. When the two disagree, believe the bytes — and then rename the file so the next person does not have to repeat the discovery.