If you have come across a .xz file or someone has sent you one for whatever reason, you may be struggling to figure out how to open it. For most, it is not a real common file format but if you work in the software world there’s a good chance you are familiar with them.
A .xz file or a file with a .xz extension is a file that contains one or more files inside of it and has been compressed. Because of this, you can’t just open them with any ordinary viewer or file utility. You need to use an application that is designed to open, decode and extract the file.
My name is Eric and I have worked as a Software Engineer for over 20 years. I have been playing around with computers since the late 1970s. I have run across many different types of file formats, so I am no stranger to figuring out how to work with them.
If you would like to see how you can extract the files and information from a .xz file, keep reading below and I will show you a couple of different options. It’s fairly simple to do, so don’t worry too much if you are a little unsure about the process.
Contents
Two Methods to Extract .xz
Extracting the contents of a .xz file is quite easy and there are two different methods you can use to do this. The first method involves using an application from your desktop and the second method uses Mac Terminal to run a command from the command line.
Both methods work well so you can choose the one that you are most comfortable with. After we quickly give you steps to do this we will discuss what compressed files are and why they are used, but for now, let’s get started so you can get your file extracted.
1. Desktop Application
For this method, all you will need is your Mac, Finder, and the location of the .xz file you wish to extract. Just follow the simple steps below and you will be on your way.
Step 1: Open Finder.
Step 2: Navigate to the location of your .xz file. If needed you can type it in the search window and find it that way.
Step 3: Right-click on the file name to bring up the context menu.
Step 4: Select Open With->Archive Utility.app
The files and folders will then be extracted into the current folder you are in.
At this point, you are done. The contents of the compressed .xz file have now been extracted and you can view them, open them, edit them or do whatever you need to do with them.
The Archive Utility is a tool that is built-in to the macOS but you could use other tools if you would like. There are plenty of applications that can be used to open compressed archive files, just do a search in the AppStore or a Google search and you can find them.
2. Mac Terminal
Using the command line will produce the same results. The only difference is that it will require just a bit of typing. If that’s not a problem, you should be able to follow along and use this method as well.
Step 1: Open the Mac Terminal application. If you can’t find it, just go to Launchpad and type Terminal in the search window and it will come up.
Step 2: Navigate to the path or location of the .xz file.
Step 3: Type the following command to extract the contents of the file:
tar xJvf YourFilename.tar.xz
For our example the file is called XZTest.tar.xz so our command would be
tar xJvf XZTest.tar.xz
Step 4: Hit the Return key.
You will see output on the screen similar to what is shown below. The output is showing the list of files that have been extracted, which is one of the nice benefits of using this method.
As you can see the extraction has created the files in the folder shown above.
The files have now been extracted and are now available to do as you wish with them.
Which Method is Better?
Both of the methods above work equally well and are great methods to extract the files from a .xz file. If you are not comfortable using Mac Terminal, then the first method may work better for you. It is quicker and does not require any typing.
The second method is one that those who are familiar with using Mac Terminal will be comfortable with. While it does require a little bit of typing, the great thing about it is that it provides an output that shows a nice listing of what has been extracted and where.
Use Caution When Extracting Files
No matter which method you use, you will want to use some caution when extracting .xz files. Make sure you know the source of the file and trust it. The last thing you want to do is extract an unknown file that could be a virus or cause other issues on your system.
Another thing to look out for is the location you will be extracting the files to. You may not know whether the .xz file contains files or folders and they will be extracted in whatever location the .xz file currently exists.
It is sometimes best to create a new empty folder, copy the .xz file to that new folder and then extract it there. This will ensure that you know where everything is going and that you can identify everything that has been extracted from that file.
What are Compressed Files?
So you’ve learned how to extract the files inside of a .xz file but if you are not familiar with compressed files, you may still be wondering what a compressed file really is. No worries, there is a straightforward explanation as to what a compressed file such as a .xz is.
A compressed file is encoded into a new format using what is called a compression algorithm to reduce the size of the file. The algorithm is run to create the compressed file and it must also be used to extract the original file or files from the compressed one.
A file that is compressed may also contain more than one file inside of it and is often the case. We sometimes compress and package whole folders into one compressed file. Once in this package, the size of all the files combined is reduced significantly from the original group of files.
Although you may not have been familiar with .xz files, you may be familiar with some other types of compressed files such as .zip files. Files that are packaged together into one single file are also sometimes called archive files and there are many types with or without compression.
Why Use Compressed Files?
Archive files are great because they give us the ability to package many different files together into one single file. This allows us to easily upload, download, email, or copy them from place to place. The addition of compression gives us even more of an advantage.
Compression can greatly reduce the size of the archive file package, thus allowing us to easily and quickly send or upload it to another location. The size reduction also takes up much less storage space on a hard drive, network drive, or cloud storage space.
Whenever we need access to the internal compressed files, it’s only a matter of running the application that can decode them and restore them back to their original state. We can then use them as normal files again.
Software that we use to create system backups and restorations normally uses compressed files to save space. We don’t usually see the files or recognize their format, but it helps backup software to easily store a copy of your system for when you need it to reinstall your system.
Installation applications also use compression. The .dmg and .cpio files that you download to install new apps are also compressed so that you can quickly download them to your computer and they can be easily transported to other computers.
It turns out that you are probably using compressed files all the time and don’t even know it.
Final Words
Extracting .xz files on your Mac can be a very simple task if you follow the steps I have outlined above. Hopefully, these will work well for you and you will be able to extract the files that you are trying to access.
Compressed files may sometimes seem like a pain to work with, but the ability to package and compress files into one smaller file is a very important and useful tool, especially when working with multiple and large files.
As always, let me know if you have any questions or comments. I would love to hear from you.