Fractures are diverse geological features. Despite extensive research on their varied geometries and growth mechanisms, there has been relatively little focus on how acid-rock interactions, such as reactive transport and precipitation, influence crack growth. To understand the chemical corrosion of sandstone exclusively from chemical reaction, we have developed a chemical corrosion model that highlights that the dissolution of calcite grains within the sandstone, coupled with the diffusion of Ca2+ ions and precipitation of calcite, contributes to time-dependent crack formation and their subsequent filling. Based on this theory, we propose a heterogeneous grain-based phase-field method (PFM) model to analyze the failure pattern and changes in ion behavior in sandstone. Our model results are in good agreement with experimental data, validating the proposed chemical corrosion theory and the grain-based PFM model. Both numerical and experimental results reveal that the chemical corrosion of sandstone is a time-dependent deterioration process that progresses from the exterior to the interior of the sample. The cracks that form act as pathways for ion transport, leading to a gradual decrease of Ca2+ ions with increasing distance from the surface of calcite grains. Following the validation of our approach, we used the heterogeneous grain-based PFM model to analyze the effect of rock heterogeneity and to simulate chemical corrosion induced by calcite grains within a sandstone sample. The numerical results reveal that a lower homogeneity index leads to a larger damaged area and accelerates crack initiation. Additionally, we identify and categorize the acid-rock interactions into three distinct stages: initial surface erosion, subsequent crack propagation, and further deepening of etched features. The proposed chemical corrosion theory enhances our understanding of the degradation and fracture mechanics of sandstone in an acidic environment, and can be further extended to elucidate the sealing of hydraulic fractures and formation and dissolution of calcite veins.