A file name extension is the short code at the end of a file name that tells your computer what program should open it
When you save a document, photo, or video, your computer adds a period followed by letters at the very end — like .docx, .jpg, or .mp4. That's the file name extension. It's not part of the actual file name you chose. It's metadata that your operating system reads to know which program can handle that file.
Without the extension, your computer would have no way to know whether a file called "vacation" is a photo, a video, a text document, or something else entirely. The extension is how Windows, Mac, or Linux figures out what to do when you double-click it.
Key Takeaways
- File extensions are the letters after the period at the end of a file name, and they tell your computer which program should open the file.
- Common extensions include .txt for text, .jpg for photos, .docx for Word documents, and .mp4 for videos.
- Changing or removing an extension can break a file, because your computer will no longer recognize what it is.
- Most operating systems hide extensions by default, but you can turn on visibility to see them and understand what type of file you're working with.
How extensions work with your operating system
Your operating system maintains a list of file extensions and which programs are associated with each one. When you double-click a file, the system reads the extension, looks up that association, and launches the correct program. If you double-click a .pdf file, your computer knows to open it with Adobe Reader or your default PDF viewer — not with Notepad or your email client.
This system works the same way on Windows, Mac, and Linux, though the default programs and the way you manage associations differ slightly. The extension itself is universal: a .jpg file is a .jpg file whether you're on Windows 10, a MacBook, or a Linux machine.
If a file has no extension, or if the extension is wrong, your computer won't know what to do with it. You'll get an error message or a dialog asking you to choose a program manually. This is why accidentally deleting or changing an extension can make a file unusable.
Common extensions and what they mean
Different types of files use different extensions. Text documents use .txt, .docx (Microsoft Word), or .odt (OpenDocument). Photos use .jpg, .png, or .gif. Videos use .mp4, .mov, or .avi. Audio files use .mp3, .wav, or .flac. Spreadsheets use .xlsx (Excel) or .csv (comma-separated values). Presentations use .pptx (PowerPoint).
The extension tells you at a glance what kind of file you're looking at, even before you try to open it. If you see a file called "report.xlsx", you know when ready it's an Excel spreadsheet. If you see "photo.jpg", you know it's a photo. This is especially useful when you're sorting through folders or deciding which program to use to open something.
Some extensions are less obvious. .zip means the file is compressed — a container holding other files squeezed down to save space. .exe on Windows means it's an executable program. .app on Mac means it's an process. .html means it's a web page. Learning the most common ones in your field saves time and prevents mistakes.
Why your operating system hides extensions by default
Windows, Mac, and Linux all hide file extensions by default. You see "vacation" instead of "vacation.jpg". This is meant to make file names look cleaner and less technical for everyday users. The operating system assumes you don't need to see the extension because it will handle opening the file correctly.
However, this default behavior can cause confusion. If you're organizing files or troubleshooting why something won't open, you need to see the extension. It's also a security risk: a malicious program could be named "document.txt.exe" — it looks like a text file but is actually an executable program. Hiding the extension makes this trick work.
Most people benefit from turning extensions on. On Windows, open File Explorer, click the View tab, and check "File name extensions". On Mac, open Finder, click Finder in the menu bar, select Preferences, go to Advanced, and check "Show all filename extensions". Once you turn this on, you'll see the full file name including the extension for every file on your computer.
What happens if you change or remove an extension
Changing a file's extension does not change what the file actually is. If you rename "photo.jpg" to "photo.txt", the file is still a photo — it's just that your computer no longer recognizes it as one. Double-clicking it will try to open it in a text editor, which will show you gibberish instead of the image.
You can change the extension back, and the file will work again. The data inside hasn't been damaged. However, some programs are stricter: if you change a Word document from .docx to .txt and then try to open it in Word, Word may refuse to open it or may corrupt it during the process. The safest rule is to never change an extension unless you have a specific reason and you understand what you're doing.
Removing the extension entirely — renaming "document.docx" to just "document" — makes the file harder to work with. Your computer won't know what program to use, and you'll have to manually choose one every time you want to open it. It's not dangerous, but it's inconvenient and defeats the purpose of having extensions in the first place.
Extensions vs. file format: what's the difference
The extension and the file format are related but not identical. The file format is the actual structure of the data inside the file — how the information is organized and encoded. The extension is just a label that tells your computer which format to expect.
In most cases, the extension matches the format. A .jpg file contains JPEG-format image data. A .docx file contains Microsoft Word format data. But it's technically possible to have a mismatch: you could have a JPEG image with a .png extension, or a Word document with a .txt extension. The file would still contain the original data, but your computer would be confused about how to handle it.
This distinction matters when you're converting files. If you open a .docx file in Google Docs and save it, you can choose to save it as .docx (Word format), .odt (OpenDocument format), or .pdf (PDF format). You're changing the actual format of the data, not just the label. The extension changes to match the new format.
How to change file associations if a file opens in the wrong program
Sometimes a file extension is associated with the wrong program. You might have a .txt file that opens in Notepad when you want it to open in a code editor, or a .jpg that opens in your email client instead of your photo viewer. You can change which program handles a particular extension.
On Windows, right-click the file, select "Open with", then "Choose another app". Select the program you want to use and check "Always use this app to open [extension] files". From then on, all files with that extension will open in your chosen program. You can also go to Settings, Apps, Default apps, and set defaults by file type.
On Mac, right-click the file, select "Open With", choose the program you want, then hold Option and click "Always Open With". This sets the default for that file type. You can also go to System Preferences, General, and manage default applications there, though Mac gives you fewer options than Windows.
Frequently Asked Questions
Can I have a file without an extension?
Yes, technically. Many files on Mac and Linux don't have visible extensions. However, the operating system still tracks the file type internally. On Windows, files almost always have extensions. A file without an extension is harder to work with because your computer won't know which program to use to open it.
What if I read a file and it has no extension?
Check if extensions are hidden on your system. If they're turned on and the file truly has no extension, you can try to open it with different programs to figure out what it is. If you know what type of file it should be, you can add the extension yourself by renaming the file — for example, renaming "document" to "document.pdf" if you know it's a PDF.
Is it safe to change a file extension?
Changing the extension doesn't damage the file, but it can make it unreadable. Your computer will try to open it with the wrong program. If you change it back, the file usually works again. The exception is some programs that validate the extension when opening — they may refuse to open a file with the wrong extension or may corrupt it.
Why do some files have multiple extensions like .tar.gz?
.tar.gz means the file was first compressed with gzip (creating .gz) and then packaged with tar (creating .tar). It's a file within a file. You need to decompress it in the right order to access the contents. Most modern tools handle this automatically when you double-click it.
Do I need to know all file extensions?
No. You only need to recognize the ones you work with regularly. If you mostly use Word documents and photos, you only need to know .docx and .jpg. If you encounter an unfamiliar extension, you can search for it online to find out what program opens it and whether it's safe.