You can change a file extension by renaming the file to end with a different three-letter code, but whether the file will actually work depends on what's inside it
A file extension is the short code at the end of a filename — the .pdf in "invoice.pdf" or the .jpg in "photo.jpg". Changing it is straightforward: you rename the file and swap out those letters. On Windows, Mac, and Linux, you do this the same way you rename any file. The harder part is knowing whether you should, because renaming a file doesn't change what the file actually contains. If you rename a Word document to end in .pdf, it's still a Word document inside — it just wears a different label.
There are legitimate reasons to change an extension: you downloaded a file that lost its extension, you need to open a file in a different program, or you're organizing files and want them grouped by type. There are also reasons not to: changing the extension of a file you don't understand can break it, and some programs won't open a file if the extension doesn't match what's inside.
Key Takeaways
- Renaming a file's extension on Windows, Mac, or Linux means right-clicking the file, selecting rename, and changing the letters after the final dot.
- Changing an extension only changes the label on the file, not the actual data inside, so a renamed file may not open or work correctly in a new program.
- Windows hides file extensions by default, so you may need to turn on "Show file extensions" in File Explorer settings before you can edit them.
- Some files need their extension changed to work — like a downloaded file that arrived without one, or a file you're converting from one format to another using a program like Handbrake or ImageMagick.
- If a renamed file won't open, you can always change the extension back to what it was, and the file will work again.
How to change a file extension on Windows
Windows hides file extensions by default, so the first step is to turn them on. Open File Explorer, click the View tab at the top, and check the box next to "File name extensions". Now you'll see the full filename including the dot and the three-letter code at the end.
Right-click the file you want to rename and select "Rename" from the menu. The filename will highlight and become editable. Change only the letters after the final dot — for example, change "document.docx" to "document.pdf". Press Enter when you're done. Windows will ask you to confirm that you want to change the extension; click "Yes".
If you don't see the View tab or the "File name extensions" option, you're probably using an older version of Windows. In that case, open File Explorer, click Tools in the menu bar, select Folder Options, click the View tab, and uncheck "Hide extensions for known file types". Click OK and close the window.
How to change a file extension on Mac
On a Mac, file extensions are usually hidden, but you can still rename them. Click once on the file to select it, then press Enter or click it again slowly (not a double-click). The filename will become editable. Change the letters after the final dot and press Enter.
If you want to see extensions all the time, open Finder, click Finder in the menu bar, select Preferences, click the Advanced tab, and check "Show all filename extensions". Close the window and extensions will appear on all your files from then on.
If a Mac dialog box appears asking whether you want to keep the old extension or use the new one, click "Use the new extension". If it warns you that changing the extension may make the file unusable, that's a real warning — proceed only if you understand what you're doing.
How to change a file extension on Linux
On Linux, file extensions are always visible. Open your file manager, right-click the file, and select "Rename". Edit the filename to change the letters after the final dot, then press Enter. Some file managers let you rename by pressing F2 with the file selected instead.
If you prefer the command line, open a terminal and use the mv command. For example, to rename "photo.jpg" to "photo.png", type mv photo.jpg photo.png and press Enter. This does exactly the same thing as renaming in the file manager.
When changing an extension actually matters
Changing an extension works when the file's actual contents match the new extension. If you use a video converter like Handbrake to turn an MP4 file into an MKV file, the program rewrites the file's internal structure. Renaming the extension from .mp4 to .mkv then makes sense because the file is actually an MKV inside.
Changing an extension also works when a file arrived without one. Some downloads lose their extension in transit, or a file was created by a program that doesn't add one automatically. If you know what type of file it is — because you created it, or because someone told you — adding the correct extension lets programs recognize and open it.
Changing an extension does not work when you're trying to convert between formats without actually converting. Renaming a Word document from .docx to .pdf doesn't turn it into a PDF; it just makes Windows or Mac think it's a PDF. When you try to open it, the program will either refuse to open it or open it and show garbage. To actually convert a file, you need a program that reads the old format and writes the new one — like Microsoft Word saving to PDF, or an online converter.
What to do if a renamed file won't open
If you changed a file's extension and now it won't open, or it opens but looks wrong, change the extension back to what it was. Right-click the file, select Rename, and restore the original extension. The file will work again.
If you don't remember the original extension, think about what program created the file or what you were doing when you got it. A file from an email attachment is usually in a standard format like PDF, Word, or image. A file you created in a specific program usually has that program's extension — Photoshop files end in .psd, Excel files in .xlsx, and so on. If you're still stuck, you can try opening the file with different programs to see which one recognizes it.
Why Windows hides extensions and what it means
Windows hides extensions by default because Microsoft assumed most people don't need to see them. The operating system uses the extension to decide which program opens the file when you double-click it, so from Windows' perspective, the extension is background information.
The downside is that hiding extensions makes it easier for malware to disguise itself. A file that looks like "document.pdf" might actually be "document.pdf.exe" — an executable program wearing a PDF label. Turning on "Show file extensions" is a small security habit that helps you spot this kind of trick. You'll see the real extension and know whether the file is what it claims to be.
Frequently Asked Questions
Can I change a file extension to make it open in a different program?
Changing the extension will make a different program try to open it, but the file won't actually work unless the program understands that file format. If you want to open a file in a program that doesn't normally handle it, look for a "Save As" or "Export" option in the program that created the file, or use a conversion tool designed for that format.
What if I change a file extension and it breaks the file?
Change the extension back to the original. Right-click the file, select Rename, and restore the old extension. The file will work again because you haven't actually changed what's inside — you've only changed the label.
Is it safe to change file extensions?
It's safe to change an extension if you understand what the file is and why you're changing it. It's risky if you're guessing or trying to convert a file without the right tool. When in doubt, make a copy of the file first, change the copy's extension, and test it. If it doesn't work, you still have the original.
Why do some files have two extensions, like .tar.gz?
Some file formats are combinations of other formats. A .tar.gz file is a TAR archive (a container) that has been compressed with gzip. You should change both extensions together if you rename it, or use a tool designed to handle that specific format.
Can I change the extension of a file I downloaded from the internet?
Yes, but be careful. If you downloaded a file and it's missing its extension, you can add one if you know what type of file it is. If you're changing the extension of a file you don't recognize or didn't create, make sure you trust the source first — changing an extension won't make a malicious file safe.