A file that displays as invoice.pdf can execute code on Windows — its full name may be invoice.pdf.exe. The letters after the dot are not a description of the contents; they are a label the operating system uses to decide what to do, and that label is trusted far more than it deserves.
An extension is a name, not a fact
The extension is the part of the filename after the last dot. Windows maps it to a default program; macOS and Linux often consult file metadata and MIME type first, but the extension still influences behavior. Nothing stops you renaming photo.png to photo.jpg; the bytes stay PNG, and some programs will misread it.
Renaming is not converting. Converting changes the data; renaming changes only the label.
A field guide to common formats
| Extension | MIME type | What it is |
|---|---|---|
| .txt | text/plain | Unformatted text |
| .html | text/html | Web page markup |
| .jpg / .jpeg | image/jpeg | Lossy photo format |
| .png | image/png | Lossless image with transparency |
| .webp | image/webp | Modern web image, lossy or lossless |
| .mp3 | audio/mpeg | Compressed audio |
| .mp4 | video/mp4 | Video container |
| application/pdf | Fixed-layout document | |
| .zip | application/zip | Archive of files |
| .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | Word document |
| .bin | application/octet-stream | Raw binary data |
Executables deserve their own warning: .exe, .msi, .bat, .cmd, .scr. A mail attachment with a double extension is a classic trick; hidden extensions make it look harmless.
Extensions and MIME types are different things
An extension is a filename convention on your disk. A MIME type is a label attached to data, usually in an HTTP Content-Type header, telling the receiver how to interpret it. The two often agree but are independent: a server can send a .jpg as image/png, and browsers may either honor the header or sniff the bytes further.
That is why a correct Content-Type matters on a web server, and why the MIME types reference lists both the type string and the matching extensions. When an upload is rejected or renders as garbage, a mismatch is a common cause.
Turn extensions on
Windows hides known extensions by default, which is how the trick above works. In File Explorer, enable the file name extensions view. On macOS, Finder’s advanced settings have a similar toggle.
Make extensions visible, and treat an unexpected executable from email or a download as hostile until proven otherwise. The extension is a claim; the bytes are the truth.