What is a file extension?

The letters after the dot in a file name tell your computer which program to use, not what the file is. How extensions work, how to see them and why they mislead.

Last updated

The .jpg in photo.jpg, the .pdf in report.pdf, the .docx in letter.docx: the letters after the last dot in a file name are its extension. They look like a description of the file. They’re really an instruction to your computer about which program to open it with.

What an extension does

When you double-click a file, the operating system looks at the extension and hands the file to the program registered for it. That is all. The extension is part of the name and changing it changes nothing inside the file, which is why renaming a file doesn’t convert it; that situation is covered in renamed a file and now it’ll not open.

What really identifies a file

Almost every file format begins with a signature, a few fixed bytes that the program reading it checks first. PNG files start with the same eight bytes, PDFs with the characters %PDF, zips with PK. Programs that care about correctness and many upload forms, check the signature rather than trusting the name.

The file type checker reads those bytes and tells you what a file really is and whether its name matches. It looks inside zips too, since Word documents, spreadsheets and e-books are zips with particular contents.

Seeing extensions

Windows and macOS hide extensions for common file types by default, so report.pdf shows as report. Turning them on (File Explorer’s View menu on Windows, Finder’s Advanced settings on a Mac) makes it much easier to see what you’re dealing with.

Why they mislead

  • Hidden extensions let invoice.pdf.exe appear as invoice.pdf, with a program disguised as a document.
  • Websites save images in a different format from the name you expect, as in why images save as WebP.
  • Old systems name CSV or HTML exports .xls so that Excel will open them.

When the format itself needs changing, not just the name, a converter such as the image converter rewrites the contents.

Common questions

How do I show file extensions on Windows?

In File Explorer, open the View menu and turn on File name extensions. Windows hides them by default, which is why some files seem to have none.

How do I show file extensions on a Mac?

In Finder, open Settings, choose Advanced and turn on Show all filename extensions.

Can a file have two extensions?

The name can, as in photo.tar.gz or invoice.pdf.exe, but only the last one decides which program opens it. The second example is a program, not a PDF.

Does the extension have to match the contents?

It should. When it doesn’t, the file fails to open in the program the name suggests and upload forms that check contents reject it.

Tools for this

More guides