Deep rock masses are typically in complex stress states, and research on the evolution of their strain energy density is of highly important for understanding their failure characteristics. In this work, a true triaxial stress‒balanced unloading test is designed to analyze the ud and ue evolution of sandstone under true triaxial compression conditions. The study results indicate that as σ1 increases, the elastic strain decreases in the σ2 and σ3 directions, whereas the residual strain progressively increases, and the magnitude of decrease in elastic strain exceeds the magnitude of increase in residual strain. Throughout the loading process of σ1, ue progressively decreases in the σ2 and σ3 directions, whereas ud gradually increases, and the magnitude of decrease in ue surpasses the magnitude of increase in ud. The ud and ue of sandstone under different stress levels were calculated via true triaxial stress‒balanced unloading tests, and the evolution of ud and ue in the three principal stress directions and the overall strain energy density of sandstone followed a linear energy storage law. On the basis of this law and the true triaxial stress‒balanced unloading test, a new method for calculating the true triaxial ud and ue was proposed. A study on the σ1 unloading stress path revealed that the σ1 unloading stress path significantly affects the storage and dissipation of the strain energy density in the three principal stress directions of sandstone. On the basis of the research results, the criteria for determining rockbursts were discussed.