File extensions are the two to four letters after the dot at the end of a filename, and they tell your operating system what program should open the file
When you save a document as "budget.xlsx", the ".xlsx" part is the extension. Your computer reads that extension and knows to open the file in a spreadsheet program like Microsoft Excel or Google Sheets. Without it, your operating system would have no idea whether "budget" is a spreadsheet, a text document, an image, or something else entirely — and it would not know which program to use.
Extensions are a form of metadata: information about the file that is separate from the file's contents. They are not required for a file to work, but they are a shorthand that saves your operating system from having to examine the actual data inside the file every time you try to open it. This system has been standard since the early days of personal computers and remains the primary way operating systems categorize and route files.
Key Takeaways
- File extensions tell your operating system which program should open a file, so changing or removing an extension can prevent the file from opening correctly.
- Common extensions like .docx, .jpg, .mp3, and .pdf are recognized by most computers and devices, while uncommon extensions may require you to install a specific program.
- Hiding file extensions in Windows or macOS can make it harder to spot suspicious files, so showing them is a security practice worth adopting.
- Changing a file's extension does not change what the file actually is — renaming "photo.jpg" to "photo.mp3" will not make it play as music.
How your operating system uses extensions to open files
When you double-click a file, your operating system checks the extension and looks it up in a registry or preference file that maps extensions to programs. On Windows, this registry lives in the system settings and can be viewed or edited through "Settings > Apps > Default apps". On macOS, the system stores this information in the Finder preferences and in individual app settings. On Linux, the mapping is typically stored in configuration files that users can edit directly.
If your computer recognizes the extension, it launches the associated program and passes the file to it. If the extension is not recognized, you will see a dialog asking you to choose a program or telling you that no program is available. This is why renaming a file with an unrecognized extension — or removing the extension altogether — can make it impossible to open without manually selecting a program each time.
Common file extensions and what they mean
Extensions are grouped by file type. Documents typically use .doc, .docx (Microsoft Word), .txt (plain text), or .pdf (portable document format). Spreadsheets use .xls or .xlsx (Excel), .csv (comma-separated values), or .ods (OpenDocument Spreadsheet). Images use .jpg, .png, .gif, or .bmp. Audio files use .mp3, .wav, .flac, or .aac. Video files use .mp4, .avi, .mov, or .mkv. Compressed archives use .zip or .rar.
The extension does not determine what program opens the file — the operating system's file association settings do. You can change which program opens a .txt file, or a .jpg file, or any other extension. But the extension itself is a label that describes the file's format, and changing it does not change the file's actual contents or structure.
Why extensions matter for security
Malicious files often rely on hiding their true nature behind a misleading extension. A file named "invoice.pdf.exe" is actually an executable program (the .exe extension is what matters), but the .pdf in the middle can trick a user into thinking it is a document. By default, Windows hides known file extensions in File Explorer, which makes this trick easier — you would see only "invoice.pdf" and not realize the .exe is there.
Turning on the display of file extensions is a straightforward security step. On Windows, open File Explorer, click the "View" tab, and check the box for "File name extensions". On macOS, open Finder, go to "Finder > Settings > Advanced", and check "Show all filename extensions". Once extensions are visible, you can spot suspicious files more easily and avoid opening programs disguised as documents.
What happens when you change or remove an extension
Changing a file's extension does not change the file itself — only the label. If you rename "photo.jpg" to "photo.mp3", the file is still a JPEG image. Your operating system will try to open it with a music player, which will fail because the file does not contain audio data. The file remains intact; the program simply cannot read it.
This is sometimes useful for troubleshooting. If a file is not opening with the correct program, you can check whether the extension is correct and change it if needed. But in most cases, changing an extension is a way to confuse your operating system or to hide what a file actually is — which is why it is a tactic used in malware distribution.
Extensions across different devices and operating systems
Most common extensions work across Windows, macOS, and Linux because they are based on open standards. A .pdf file opens in a PDF reader on any operating system. A .jpg image opens in an image viewer on any device. But some extensions are platform-specific: .exe files run only on Windows, .app files run only on macOS, and .deb files install software only on Linux-based systems.
Mobile devices like iPhones and Android phones also use extensions, but they are often hidden from the user. When you download a photo or document on a phone, the extension is there in the file system, but the phone's interface does not show it. This is by design — phones are meant to be simpler than computers, and the operating system handles file associations automatically without asking the user.
How to change which program opens a file type
If you want a different program to open files with a certain extension, you can change the default association. On Windows, right-click a file with that extension, select "Open with > Choose another app", pick the program you want, and check "Always use this app to open [extension] files". On macOS, select a file with that extension, press Command+I to open the Info window, go to "Open with", choose your program, and click "Change All".
You can also change defaults through system settings. On Windows, go to "Settings > Apps > Default apps" and scroll to the extension you want to change. On macOS, go to "System Settings > General > Default apps" (on newer versions) or use the "Get Info" method above. On Linux, the process varies by desktop environment, but most allow you to right-click a file and choose "Open with" or to edit file associations through system settings.
Frequently Asked Questions
Can I open a file if I delete its extension?
You can, but it is harder. Your operating system will not know which program to use, so you will have to manually select one each time. If you know the file type, you can add the correct extension back and the file will open normally. If you do not know the type, you can try opening it with different programs until one works.
Why do some files have multiple extensions, like .tar.gz?
.tar.gz means the file was first compressed with gzip (creating a .gz file) and then packaged into a tar archive (creating the .tar). Your operating system reads the rightmost extension (.gz) first, but some programs recognize the full .tar.gz pattern and know to decompress and unpack in one step. You can treat it as a single extension for practical purposes.
Is it dangerous to change a file's extension?
Changing an extension on a file you own is not dangerous to your computer — it just makes the file harder to open. But receiving a file with a misleading extension (like a .exe disguised as a .pdf) is a common malware tactic. Always check the full extension of files you download, especially from untrusted sources.
Do I need to know the extension to save a file?
No. Most programs add the extension automatically when you save. If you type "budget" in Microsoft Excel and click Save, Excel adds .xlsx automatically. You can type the extension yourself if you want a different format, but the program handles it by default.
What if a program does not recognize a file extension?
Your operating system will ask you to choose a program to open it with, or it will tell you no program is available. If you know the file type, you can install a program that handles it, or you can try opening it with a program you already have. Some programs like VLC media player or 7-Zip can open many different file types.