What Is A File Extension?

A file extension, or filename extension, is a suffix at the end of a computer file. It comes after the period, and is usually two-four characters long. If you’ve ever opened a document or viewed a picture, you’ve probably noticed these letters at the end of your file.

File extensions are used by the operating system to identify what apps are associated with what file types—in other words, what app opens when you double-click the file. For example, a file named “awesome_picture.jpg” has the “jpg” file extension. When you open that file in Windows, for example, the operating system looks for whatever app is associated with JPG files, opens that app, and loads the file.

What Types Of Extensions Are There?

There are many different types of file extensions—way too many to list in an article—but here a few examples of common file extensions you might see floating around on your computer:

  • DOC/DOCX:  A Microsoft Word document. DOC was the original extension used for Word documents, but Microsoft changed the format when Word 2007 debuted. Word documents are now based on the XML format, hence the addition of the “X” at the end of the extension.
  • XLS/XLSX: – A Microsoft Excel spreadsheet.
  • PNG: Portable Network Graphics, a lossless image file format.
  • HTM/HTML: The HyperText Markup Language format for creating web pages online.
  • PDF:  The Portable Document Format originated by Adobe, and used to maintain formatting in distributed documents.
  • EXE: An executable format used for programs you can run.

And like we said, this is just a smattering of the file extensions out there. There are literally thousands.

It’s also important to be aware that there are file types out there that are inherently risky, and could be dangerous. Typically, these are executable files that can run certain types of code when you try to open them. Play it safe and don’t open files unless they come from a trusted source.

RELATED: 50+ File Extensions That Are Potentially Dangerous on Windows

What If I Don’t See File Extensions on My Files?

By default, Windows shows file extensions. For a while—in Windows 7, 8, and even 10—this was not true, but fortunately, they changed the default settings. We say fortunately because we feel showing file extensions is not only more helpful, but more secure. Without file extensions showing, it can be hard to tell whether that PDF file you’re looking at (for example) is really a PDF file and not some malicious executable file.

If file extensions are not showing for you in Windows, they’re easy enough to turn back on. In any File Explorer window, just head to View > Options > Change folder and search options. In the Folder Options window, on the View tab, disable the “Hide extensions for known file types” check box.

RELATED: How to Make Windows Show File Extensions

File extensions do not show up in macOS by default. The reason for this is that macOS doesn’t really use extensions the same way that Windows does (and we’ll talk about that more in the next section).

You can make macOS show file extensions, though, and it’s probably not a bad idea to do so. With Finder open, just head to Finder > Preferences > Advanced, and then enable the “Show all filename extensions” check box.

How Do macOS And Linux Use File Extensions?

So, we talked about how Windows uses file extensions to know what type of file it’s dealing with, and what app to use when you open the file. Windows knows that a file named readme.txt is a text file because of that TXT file extension, and it knows to open it with your default text editor. Delete that extension, and Windows won’t know what to do with the file anymore.

While macOS and Linux still use file extensions, they don’t rely on them like Windows does. Instead, they use something called MIME types and creator codes to determine what a file is. This information is stored within the header of the file, and both macOS and Linux use that information to determine what type of file they’re dealing with.

Since file extensions aren’t really required on macOS or Linux, you could very well have a valid file with no extension, but the OS could still open the file with the right program because of the file information contained in the file header.

We won’t dive too much more into this here, but if you’re interested in learning more, check out our guide to why Linux and macOS don’t need file extensions.

RELATED: MIME Types Explained: Why Linux and Mac OS X Don’t Need File Extensions

What Happens If I Change A File’s Extension?

Based on what we just talked about in the previous section, what happens when you change a file’s extension kind of depends on what operating system you’re using.

In Windows, if you delete a file extension, Windows no longer knows what to do with that file. When you try to open the file, Windows will ask you what app you want to use. If you change an extension—say you rename a file from “coolpic.jpg” to “coolpic.txt”—Windows will try to open the file in the app associated with the new extension, and you’ll either get an error message or an opened, but useless, file. In this example, Notepad (or whatever your default text editor is) did open our “coolpic.txt” file, but it’s just a garbled mess of text.

For that reason, Windows warns you whenever you try to change a file’s extension, and you have to confirm the action.

If you’re using macOS, something similar happens. You still get a warning message if you try to change a file’s extension.

If you change the extension to something else, macOS will try to open the file in the app associated with the new extension. And, you’ll either get an error message or a garbled file—just like in Windows.

What’s different from Windows is that if you try to delete a file’s extension in macOS (at least in the Finder), macOS just adds the same extension right back, using data from the file’s MIME type.

If you actually want to change a file’s type—say for example, you wanted to change an image from the JPG to PNG format—you’d need to use software that can actually convert the file.

How to Change the Program That Opens a File

Whenever you install an app that can open a particular file type, that app and the file extension get registered with your operating system. It’s entirely possible to have multiple apps that can open the same type of file. You can fire up an app, and then load any supported file type into it. Or, you can right-click a file to open its context menu and choose an available app there.

For example, in the image below, you can see that we’ve got a number of image apps on our Windows system that can open the “coolpic.jpg” file we’ve right-clicked.

However, there’s also a default app associated with each extension. It’s the app that opens when you double-click a file, and in Windows it’s also the app that appears at the top of the list you get when you right-click a file (IrfanView in the image above).

And you can change that default app. Just head to Settings > Apps > Default Apps > Choose default apps by file type. Scroll through the (very long) list of file types to find the one you want, and then click the currently-associated app on the right to change it. Check out our full guide to setting your default apps in Windows for more information.

RELATED: Beginner Geek: 7 Ways You Can Change Default Applications and File Associations in Windows

And you can do the same thing in macOS. Just select a file of the type you want to change, and then select File > Get Info from the main menu. In the Info window that pops up, head down to the “Open With” section, and then use the dropdown menu to select a new app. Easy enough.

RELATED: How to Change the Default Application for a File Type in Mac OS X

Image Credit: CC0 Creative Commons/Pixabay

Brady Gavin is a passionate writer, tech aficionado, and a programmer at heart. He enjoys traveling and experimenting in the kitchen with international flavours. When he's not enjoying the blazing sun in Vietnam, you'll find him writing away in a coffee shop, sipping on an iced Vietnamese coffee to cope with the heat. Like any good Canadian, he loves hockey and a strong IPA.