The deformation and failure of sandstone samples are closely related to energy changes in the material. To explore the energy evolution during the process of sandstone sample damage, loading and unloading tests with different test paths were conducted. The results show that more energy is stored and consumed before the stress reaches its peak, while after the peak stress, more energy is released and consumed. Energy dissipation increases internal cracking, leads to sample damage and lithologic deterioration, and reduces the bearing capacity of the sample. During triaxial unloading of the confining pressure, the higher the initial unloading confining pressure, the more the elastic energy stored, and the more the energy released when the sandstone sample fails, resulting in more severe damage. Therefore, during the excavation of high-stress rock masses, large amounts of elastic energy stored in sandstone can be rapidly released, leading to rock burst disasters. Additionally, during triaxial unloading confining pressure tests, the damage in sandstone when the sample is close to failure increases more rapidly than that during conventional triaxial compression tests because of the unloading effect of the confining pressure. This phenomenon also illustrates that the failure of sandstone induced by unloading is more sudden than that induced by loading.