You can change a file's extension by renaming it, but the file type itself doesn't always change
A file extension is the suffix after the dot in a filename — like .txt, .jpg, or .pdf. Changing the extension is straightforward: you rename the file and type a new extension. But here's the catch: renaming the extension doesn't convert the file to a different format. A photo saved as .jpg remains a photo file even if you rename it to .txt. The file's actual contents stay the same. Changing the extension only tells your computer what program to use when you open it.
This matters because opening a file with the wrong extension can produce errors, corrupted displays, or programs that refuse to open it. If you need to actually convert a file from one format to another — say, from .jpg to .png — you need conversion software, not just a rename.
Key Takeaways
- Renaming a file extension is done by right-clicking the file, selecting rename, and typing a new extension after the dot.
- On Windows, you may need to show file extensions first by opening File Explorer options and unchecking "Hide extensions for known file types".
- Changing the extension does not convert the file's actual format — a .jpg renamed to .txt is still a photo file.
- Some programs will refuse to open a file with the wrong extension, while others will open it and display garbage or errors.
How to change a file extension on Windows
Windows hides file extensions by default, so your first step is to make them visible. Open File Explorer, click the View tab at the top, then click Options (or Settings, depending on your Windows version). In the window that opens, find the checkbox that says "Hide extensions for known file types" and uncheck it. Click Apply and OK. Now you'll see the full filename including the extension on every file.
Once extensions are visible, right-click the file you want to rename. Select Rename from the menu. The filename will highlight and become editable. Change only the extension — the part after the final dot — to whatever you want. For example, change document.txt to document.docx. Press Enter. Windows will ask you to confirm the change; click Yes. The file is now renamed, and your computer will try to open it with the program associated with the new extension the next time you double-click it.
How to change a file extension on Mac
On Mac, extensions are usually visible by default, but if yours are hidden, open Finder, click Finder in the menu bar, then Preferences. Click the Advanced tab and check "Show all filename extensions". Close the window.
To rename a file, click it once to select it, then press Enter (or click it again slowly, not a double-click). The filename becomes editable. Change the extension and press Enter. Mac will ask whether you want to keep the old extension or use the new one; select "Use the new extension". The file is renamed and will open with the program associated with the new extension.
How to change a file extension on Linux
Linux file managers vary, but most show extensions by default. In GNOME Files (the standard on Ubuntu and many other distributions), right-click the file and select Rename. Edit the filename, change the extension, and press Enter. The file is renamed immediately.
If you prefer the command line, open a terminal and use the mv command: mv oldname.txt newname.docx. Replace oldname.txt with your current filename and newname.docx with the new name and extension you want. Press Enter and the file is renamed.
When changing the extension actually breaks the file
Some programs are strict about extensions. Microsoft Word, for example, will refuse to open a .docx file that you've renamed to .txt, even though the file's contents haven't changed. Other programs are more forgiving — many image viewers will open a .jpg file even if you rename it to .png, because they recognize the actual image data inside.
If you rename a file and then can't open it, the extension mismatch is usually the problem. Rename it back to the original extension and try again. If you genuinely need to convert a file from one format to another, use conversion software: for images, try GIMP (free, all platforms) or online converters; for documents, use LibreOffice (free, all platforms) or the original program that created the file.
Why you might want to change a file extension
The most common reason is to open a file with a different program. If you have a text file saved as .txt but you want to edit it in a spreadsheet program, renaming it to .csv might work — though the file's actual structure has to match what the program expects. Another reason is to hide a file type: renaming a photo to .txt won't actually hide it from someone looking at your files, but it will prevent it from opening automatically when clicked.
Sometimes you'll receive a file with the wrong extension by mistake — a photo labeled .doc, for example. Renaming it to .jpg won't fix a corrupted file, but it will let the right program try to open it. If the file still won't open after renaming, the problem is usually the file itself, not the extension.
The difference between renaming and converting
Renaming changes only the label your computer sees. Converting changes the actual data inside the file. When you rename a .jpg to .png, you have a photo file with a .png label — but it's still stored as JPEG data. A real PNG file stores data in PNG format, which is different. Some programs can read both and won't care; others expect the data to match the extension and will fail.
If you need a true conversion, use software designed for it. Most image editors (GIMP, Photoshop, Paint.NET) can open a file in one format and save it in another. For documents, LibreOffice can open .docx files and save them as .pdf, .odt, or other formats. Online converters exist for almost every file type, though uploading sensitive files to the internet carries privacy risks — it's safer to use software on your own computer when possible.
Frequently Asked Questions
Will changing the extension damage my file?
Renaming the extension itself does not damage the file. The data inside stays exactly the same. What changes is which program tries to open it. If the program doesn't recognize the file's actual format, it may display an error or show garbage, but the original file is unharmed. You can always rename it back.
Can I change a .jpg to a .png just by renaming it?
You can rename it, and most image viewers will still open it because they recognize the actual image data. But you won't have a true PNG file — you'll have JPEG data with a PNG label. If you need a real PNG file with PNG compression and features, use image software to open the .jpg and save it as .png.
Why does my file refuse to open after I changed the extension?
The program associated with the new extension doesn't recognize the file's actual format. Rename it back to the original extension. If it still won't open, the file itself may be corrupted, not the extension. Try opening it with a different program or checking whether the file downloaded or transferred correctly.
Can I change a file extension to hide what type of file it is?
Renaming the extension hides it from automatic opening — double-clicking won't launch the file — but anyone looking at your file list will still see the extension you gave it. It's not a security measure. If you need to actually protect a file, use encryption or password protection instead.
What if I don't know what extension to use?
If you're trying to open a file in a specific program, check that program's documentation for which file types it accepts. If you're trying to convert a file, search for "[current format] to [desired format] converter" and use software designed for that conversion. Guessing at extensions usually doesn't work.