gzip and xz compress files, but choosing between them is not simply choosing the smallest extension. The GNU gzip manual documents .gz output; XZ Utils documents .xz output and configurable compression settings. This comparison reads their manuals and does not claim a measured winner for size or speed.

The xz manual makes an important deployment point: compression settings influence how much memory the recipient needs to decompress the result. Its memory use can vary widely. For an appliance, recovery environment or older machine, check the destination limits before selecting an aggressive preset on a powerful workstation.

Both manuals provide a keep option for retaining input files. Their usual file-based operation can remove the original after successful compression, so do not experiment on the only copy. Use disposable copies and confirm both the compressor version and the recipient’s available decompressor before adopting a format.

Choose gzip when .gz is required by the receiving workflow; evaluate xz when the destination supports it and you can budget memory explicitly. Compare representative files locally, recording time, size and successful restoration. Neither tool choice replaces an archive-layout plan or a backup, and no affiliate offer or benchmark is implied.