A file extension is the short code at the end of a filename that tells your computer what kind of file it is and which program should open it
When you save a document, photo, or video, the filename usually ends with a dot followed by two to four letters. That ending is the extension. For example, a Word document might be named budget.docx, where .docx is the extension. A photo might be vacation.jpg, where .jpg is the extension. The extension is not decoration — it is instructions. Your computer reads it and decides what to do with the file.
Without an extension, your computer has to guess. It might guess wrong, or refuse to open the file at all. With an extension, it knows exactly which program to use. When you double-click a file, your operating system looks at the extension first, then launches the right process to display or play it.
Key Takeaways
- The extension is the letters after the final dot in a filename, and it tells your computer what type of file it is.
- Common extensions include .docx for Word documents, .pdf for PDFs, .jpg for photos, .mp4 for videos, and .xlsx for spreadsheets.
- Changing or removing an extension does not change what the file actually is — it only confuses your computer about how to open it.
- Different operating systems (Windows, Mac, Linux) recognize the same extensions, so a .pdf file works the same way on any computer.
How your computer uses the extension to open files
When you double-click a file, your operating system does not look inside the file to figure out what it is. That would be slow. Instead, it looks at the extension and checks its internal list of which program handles which extension. On Windows, this list is stored in the Registry. On a Mac, it is stored in system preferences. On Linux, it is in configuration files.
If your computer recognizes the extension, it launches the correct program automatically. If it does not recognize it, you get an error message or a dialog asking you to choose a program. This is why renaming a file and changing its extension can break it — you have not changed what the file actually contains, only what your computer thinks it should do with it.
Common file extensions and what they mean
Different types of files have different extensions. Here are the ones you will encounter most often:
| Extension | File Type | What Opens It |
|---|---|---|
| .docx | Word document | Microsoft Word, Google Docs, LibreOffice |
| Portable Document Format | Adobe Reader, web browser, most systems | |
| .xlsx | Excel spreadsheet | Microsoft Excel, Google Sheets, LibreOffice |
| .jpg or .jpeg | Photo or image | Photos app, web browser, image viewer |
| .png | Image with transparency | Photos app, web browser, image viewer |
| .mp4 | Video file | VLC, Windows Media Player, web browser |
| .mp3 | Audio file | iTunes, Windows Media Player, Spotify |
| .txt | Plain text | Notepad, TextEdit, any text editor |
| .zip | Compressed folder | Windows Explorer, Mac Finder, Archive Utility |
The same extension works the same way on Windows, Mac, and Linux. A .pdf file is a .pdf file no matter what computer opens it. This is why extensions are useful for sharing files — the person receiving your file does not need to guess what program to use.
Why you should not change or hide extensions
Some operating systems hide extensions by default to make filenames look cleaner. On Windows, you can turn this off in File Explorer settings. On a Mac, you can turn it off in Finder preferences. Hiding extensions is convenient until you need to troubleshoot a file that will not open, or until you accidentally rename a file and break it.
Changing an extension does not convert a file from one type to another. If you rename photo.jpg to photo.docx, you have not turned a photo into a Word document. You have only told your computer to try opening a photo with Word, which will fail. The file itself is still a photo. To actually convert a file, you need a program that reads the original format and saves it in the new format.
Malware sometimes hides behind misleading extensions. A file named document.pdf.exe looks like a PDF but is actually an executable program. The .exe at the end is what matters — that is the real extension. This is why seeing full extensions is a security advantage: it helps you spot files that are not what they claim to be.
What happens when a file has no extension
Files without extensions still contain data, but your computer cannot tell what kind of data. If you try to open one, your system will either refuse or ask you to choose a program. You can add an extension to tell your computer what to do, but only if you know what type of file it actually is.
Some systems, especially Linux and older Unix computers, do not rely on extensions at all. They read the actual contents of the file to determine its type. This is more reliable but slower. Most personal computers use extensions because they are fast and straightforward.
Extensions versus file format
The extension and the file format are related but not identical. The format is what the file actually contains — the structure and encoding of the data inside. The extension is just a label on the outside. In most cases they match: a .jpg file contains JPEG image data, and a .docx file contains Word document data.
But they can mismatch. You can rename a .jpg file to .txt, and the extension will no longer match the format. Your computer will try to open a photo as text and fail. Or you can have a file with no extension at all — the format is still there, but the label is missing. This is why extensions matter: they are the quickest way for your computer to find the right program.
Frequently Asked Questions
Can I change a file extension to convert it to a different format?
No. Changing the extension only changes the label, not the actual data inside. To convert a file from one format to another, you need a program that reads the original format and saves it as the new one. For example, to turn a .jpg photo into a .png, you would use an image editor like Photoshop or Preview, not just rename the file.
Why do some files have two extensions, like .tar.gz?
Some files are processed in layers. A .tar.gz file is first compressed with gzip (the .gz part), then bundled into a tar archive (the .tar part). You have to decompress it in the right order to get the original files out. This is common on Linux and Mac systems, less common on Windows.
What should I do if my computer does not recognize a file extension?
First, make sure you have the right program installed. If you have a .docx file but no Word or compatible program, install one. If you have an unusual extension you do not recognize, search for it online to find out what program opens it. If the file came from someone else, ask them what program they used to create it.
Is it safe to open a file with an unfamiliar extension?
Be cautious. If someone sends you a file with an extension you do not recognize, ask them what it is before opening it. Malware sometimes uses fake or unusual extensions to trick you. If the extension does not match what the person said they were sending, do not open it.
Do I need to include the extension when I save a file?
No. Most programs add the extension automatically when you save. If you type budget in the filename field of Excel, it saves as budget.xlsx without you typing the extension. You only need to type the extension yourself if the program does not add it automatically, which is rare.