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's the file extension. It's a label that tells your operating system which program should open the file and how to read the data inside. Without it, your computer would have no way to know whether a file contains text, an image, audio, or something else entirely.

The extension is separate from the filename itself. If you save a document called "Budget 2024.docx", the filename is "Budget 2024" and the extension is ".docx". Your computer uses the extension to decide what to do when you double-click the file — it looks for a program that knows how to handle .docx files and opens it there.

Most of the time, your operating system adds the extension automatically when you save. You type a name, pick a format from the save menu, and the system tacks on the right extension. But understanding what extensions do helps you troubleshoot when files won't open, and it explains why renaming a file's extension doesn't actually change what's inside.

Key Takeaways

  • A file extension is the letters after the dot at the end of a filename, and it identifies what type of file it is to your computer.
  • Your operating system uses the extension to match the file with the correct program to open it.
  • Changing a file's extension in the filename does not change the file itself — it just confuses your computer about how to open it.
  • Common extensions include .docx for Word documents, .jpg for photos, .mp4 for videos, and .pdf for portable documents.
  • On Windows, you can show or hide extensions in File Explorer settings; on Mac, extensions are usually hidden by default but can be revealed.

How your computer matches files to programs

When you double-click a file, your operating system reads the extension and searches for a program registered to handle that type. On Windows, this information lives in the registry — a database that links extensions to programs. On Mac, the system checks a similar database. If you have multiple programs that can open the same extension, your computer uses the default you've set, or it asks you which program to use.

This is why a file with no extension, or a wrong extension, often won't open. Your computer doesn't know what program to try. You might see an error message like "Windows cannot open this file" or a dialog asking you to choose a program. The file itself is fine — your computer just doesn't know how to read it.

You can change which program opens a file type by right-clicking the file, selecting "Open with" (Windows) or "Open with" (Mac), and choosing a different program. You can also set a new default for that extension in your system settings, so all files of that type open in your preferred program from then on.

Common file extensions and what they mean

Different types of files use different extensions. Documents typically use .docx (Microsoft Word), .xlsx (Excel spreadsheet), .pdf (portable document), or .txt (plain text). Images use .jpg, .png, .gif, or .bmp. Videos use .mp4, .mov, .avi, or .mkv. Audio files use .mp3, .wav, or .flac. Compressed folders use .zip or .rar.

The extension usually reflects the file format — the way the data is organized and encoded inside. A .jpg file uses JPEG compression, which makes photos smaller. A .png file uses PNG compression, which keeps more detail. A .docx file is actually a compressed folder containing XML code and other data that Microsoft Word knows how to reassemble into a readable document. The extension tells your computer which format to expect, so it can unpack and display the data correctly.

You don't need to memorize extensions. Most of the time you'll never think about them — your programs handle them in the background. But when you're saving a file and the save dialog asks you to choose a format, you're really choosing an extension. And when a file won't open, checking the extension is often the first troubleshooting step.

Why you shouldn't rename a file's extension

A common mistake is renaming a file's extension to try to change its type. For example, renaming "photo.jpg" to "photo.png" does not turn a JPEG photo into a PNG photo. It just changes the label. The file still contains JPEG data inside. When you try to open it, your computer will try to read it as PNG data, which won't work — you'll get an error or a corrupted image.

Renaming an extension can be useful in one specific situation: when you need to open a file in a program that doesn't recognize its current extension. For example, some text editors won't open .log files, but they will open .txt files. Renaming the extension might let you open it. But this is a workaround, not a real conversion. The file's actual format hasn't changed.

If you actually need to convert a file from one format to another — say, from JPEG to PNG, or from .docx to .pdf — you need to use a program that can read the original format and save it in the new one. The program does the real work of converting the data. Simply renaming the extension is just relabeling the box without changing what's inside.

Showing and hiding extensions on your computer

On Windows, file extensions are usually visible by default in File Explorer. You see the full filename including the dot and letters at the end. If you want to hide them, open File Explorer, click the "View" tab at the top, and check the box next to "File name extensions" to toggle them off. Unchecking it hides them; checking it shows them again.

On Mac, extensions are hidden by default in Finder. To show them, open Finder, click "Finder" in the menu bar, select "Settings", go to the "Advanced" tab, and check the box next to "Show all filename extensions". From then on, you'll see extensions on all your files. You can also reveal the extension for a single file by right-clicking it, selecting "Get Info", and checking "Hide extension" to toggle it.

There's no right answer to whether you should show or hide extensions. Showing them gives you more information and makes it easier to troubleshoot file problems. Hiding them makes the desktop look cleaner and prevents accidental renaming of the extension. Choose whichever works better for how you use your computer.

What happens when a file has no extension

Files without extensions are common on Mac and Linux systems, where the operating system can identify file types in other ways. On Windows, a file without an extension will usually cause problems. Your computer won't know what program to use, and double-clicking it won't open anything — you'll get an error instead.

If you have a file with no extension and you know what type it is, you can add the extension yourself. Right-click the file, select "Rename", and type the filename plus the dot and extension. For example, rename "MyDocument" to "MyDocument.docx". Your computer will then recognize it and open it with the correct program.

Be careful when renaming — make sure you're adding the right extension for the file type. If you're not sure what type the file is, you can try opening it with different programs to see which one works. Once you find the right program, you'll know what extension to add.

File extensions and security

File extensions matter for security too. Malicious files often use extensions that trick you into opening them. For example, a file named "Document.pdf.exe" looks like a PDF at first glance, but the real extension is .exe — an executable program that can run code on your computer. If extensions are hidden, you might only see "Document.pdf" and think it's safe to open.

This is one reason to show file extensions on your computer, especially if you download files from the internet or receive them by email. You can see the true extension and spot suspicious files before opening them. Be wary of executable extensions like .exe, .bat, .cmd, .com, and .scr, especially if they come from unknown sources.

Your antivirus software also uses extensions to identify potentially dangerous files. But the extension alone isn't enough protection — a malicious file can have any extension. Always be cautious about opening files from untrusted sources, regardless of what the extension says.

Frequently Asked Questions

Can I change a file's extension to open it in a different program?

Renaming the extension might let you open the file in a program that doesn't recognize the original extension, but it won't convert the file's actual format. The file still contains the same data inside. If the program can't read that data, you'll get an error or corrupted output. To truly convert a file, use a program designed to read the original format and save it in the new one.

Why does my file have two extensions, like .tar.gz?

Some files use two extensions because they've been processed twice. A .tar.gz file is a folder that was first compressed with tar, then compressed again with gzip. You need to decompress it twice to get to the original files. Other double extensions are less common, but they follow the same idea — each extension represents one step in how the file was created.

What if a file won't open even though it has the right extension?

The file might be corrupted, or you might not have the right program installed. Try opening it with a different program — right-click the file, select "Open with", and choose an alternative. If nothing works, the file may have been damaged during download or transfer. Try downloading or copying it again.

Do I need to add an extension when I save a file?

No. When you save a file, your program automatically adds the extension based on the format you choose in the save dialog. You only type the filename itself. If you want a specific extension, make sure you've selected the right format before saving.

Can a file have more than one extension at once?

A file can only have one primary extension — the letters after the final dot. But as mentioned above, some files have two extensions in a row, like .tar.gz. Your computer reads the final extension to decide which program to open, so .tar.gz files are treated as .gz files first.