A file extension is the short code at the end of a filename that tells your computer what kind of file it is
When you save a document, photo, or video, the filename ends with a dot followed by a few letters — like .docx, .jpg, or .mp4. That ending is the file extension. It is a label that tells your operating system which program should open the file and how to read the data inside it. Without the extension, your computer would have no way to know whether a file contains a spreadsheet, an image, or a video.
Extensions are not something you add for decoration. They are part of how your computer's filing system works. When you double-click a file, Windows or Mac looks at the extension first, then launches the program that knows how to handle that type of file. If the extension is missing or wrong, the file will not open, or it will open in the wrong program.
Key Takeaways
- A file extension is the letters after the final dot in a filename, and it identifies what kind of file it is to your computer.
- Common extensions include .txt for text, .pdf for documents, .jpg for photos, and .xlsx for spreadsheets — each one tells your computer which program to use.
- Changing or hiding an extension can break a file or make it open in the wrong program, so leave extensions alone unless you know what you are doing.
- Most programs add the correct extension automatically when you save, so you usually do not have to type it yourself.
How extensions work on Windows and Mac
Your computer stores a list of which extensions belong to which programs. When you double-click a .docx file, Windows checks that list and opens Microsoft Word (or another word processor). When you double-click a .jpg, it opens your photo viewer. This matching system is called file association, and it runs in the background every time you open a file.
By default, Windows hides file extensions from view. You see the filename but not the .docx or .jpg at the end. This is meant to make the desktop less cluttered, but it can cause confusion. Mac shows extensions by default, so you see the full filename including the dot and letters. If you want to see extensions on Windows, you can turn them on in File Explorer settings — go to View, then check the box for "File name extensions."
Changing an extension does not actually change what the file is. If you rename a photo from photo.jpg to photo.txt, the file is still a photo. Your computer will just try to open it as text, which will fail or show garbage. The data inside the file has not changed — only the label has.
Common file extensions and what they mean
You will see the same extensions over and over. .txt is plain text with no formatting. .docx is a Word document. .pdf is a portable document that looks the same on any computer. .xlsx is an Excel spreadsheet. .jpg and .png are image formats — jpg is smaller but loses quality, png keeps quality but takes up more space. .mp4 and .mov are video files. .mp3 is audio.
Each extension represents a different way of storing data. A .jpg file uses compression to make photos smaller. A .pdf locks the formatting so the document looks identical whether someone opens it on a phone, tablet, or computer. A .docx file stores not just text but also fonts, colors, and layout information. Knowing the extension tells you what kind of information is packed inside and which program knows how to unpack it.
When you download a file from the internet, the extension is already attached. When you save a file in a program like Word or Photoshop, the program adds the correct extension automatically. You type the filename, the program adds the dot and extension, and you end up with something like "report.docx" or "vacation.jpg."
Why you should not change or hide extensions
Changing a file extension is one of the easiest ways to break a file by accident. If you rename "budget.xlsx" to "budget.jpg" because you want it to look like an image, you have not turned it into an image — you have just mislabeled it. When you try to open it, your computer will try to read spreadsheet data as if it were a photo, and it will fail.
Hiding extensions can also cause problems. If you cannot see the extension, you might accidentally save over a file you meant to keep, or you might not realize a file is corrupted or incomplete. Some people hide extensions to make their desktop look cleaner, but the trade-off is that you lose information about what each file actually is.
There are rare cases where you need to change an extension — for example, if a file was saved with the wrong one by mistake, or if you are converting between formats. But these are exceptions. In normal use, leave extensions alone and let your programs handle them.
What happens when a file has no extension
A file without an extension is like a package with no label. Your computer does not know what program should open it. You might see an error message, or the file might open in a random program that does not know how to read it. On Windows, you can right-click the file and choose "Open with" to pick a program manually, but this is a workaround, not a solution.
Files sometimes lose their extensions when they are transferred between computers, downloaded from certain websites, or moved through email. If this happens, you can usually add the extension back by renaming the file. If you know it is a Word document, rename it to add .docx at the end. If it is a photo, add .jpg. Your computer will then recognize it and open it correctly.
Extensions and file security
Scammers sometimes use extensions to hide what a file really is. A malicious program might be named "invoice.pdf" but actually be an .exe file (an executable program) with the extension hidden. When you double-click it, the malicious program runs instead of opening a document. This is why it is important to keep extensions visible and to be suspicious of files that claim to be one type but have an extension that does not match.
If you receive a file from someone you do not know, check the extension before opening it. Legitimate documents end in .pdf, .docx, or .xlsx. Executable files end in .exe, .bat, or .com — these are programs, not documents, and you should not run them unless you are certain they are safe. When in doubt, ask the person who sent it what the file is supposed to be.
Frequently Asked Questions
Can I open a file with the wrong extension?
Sometimes. If you rename a .jpg to .png, the image will usually still open because both formats are image files. But if you rename a spreadsheet to .txt, it will not work — the program will not understand the data. Right-clicking and choosing "Open with" lets you pick a program manually, but the file may not display correctly.
Why do some files have double extensions like .tar.gz?
Double extensions mean the file has been processed twice. A .tar.gz file was first compressed with tar, then compressed again with gzip. You need to decompress it twice to get the original file. These are common in software development and Linux, but rare in everyday use.
What if I accidentally changed a file extension and now it will not open?
Rename it back to the original extension. Right-click the file, choose Rename, and change the extension back to what it was. If you do not remember the original extension, right-click and choose "Open with" to pick a program that might work, or ask whoever sent you the file what type it is.
Do I need to type the extension when I save a file?
No. When you save in Word, Photoshop, or most other programs, the extension is added automatically. If you type the extension yourself, you might end up with something like "report.docx.docx." Let the program handle it.
Why does my computer show .exe files differently than other files?
.exe files are programs, not documents. Windows treats them differently because running the wrong .exe can harm your computer. If you see a .exe file from an unknown source, do not open it. Legitimate software comes from trusted websites or app stores, not random downloads.