The sandstone is in a state of dry–wet cycle under the repeated action of rainfall, and its mechanical properties are deteriorated to varying degrees, which causes cracks in the sandstone. Therefore, it is of great significance to study the mechanical properties and fracture propagation of sandstone under the action of dry–wet cycles. Currently, there are limited studies using numerical simulation methods to study the fracture extension of rocks under various dry and wet cycling conditions.Therefore, in this paper, the effects of different amounts of dry and wet cycling on the mechanical properties and fracture behavior of sandstone are investigated through uniaxial compression tests and numerical simulations of fracture extension. The findings indicate that the deformation stage of sandstone remains unchanged by the dry–wet cycle. The uniaxial compressive potency and coefficient of restitution gradually diminish as the quantity of cycles rises, while the Poisson's ratio exhibits the opposite trend, and the impact on the mechanical performance of sandstone wanes with cycle increments, and the correlation coefficient surpasses 0.93, signifying a substantial influence of the dry–wet cycle on sandstone's mechanical performances. The discrepancy between the numerical simulation and experimental results is minimal, with a maximum error of only 3.1%, demonstrating the congruence of the simulation and experimental outcomes.The mesoscopic examination of the simulations indicates that the quantity of fractures in the sandstone specimens rises with the escalation of dry–wet cycles, and the steps of analysis linked to crack inception and fracture propagation are accelerated, and the analysis steps from fracture initiation to penetration are also reduced.