The ecological stoichiometric characteristics of soil elements have greatly enhanced our understanding of the circulation of soil nutrients. However, there is limited knowledge regarding the alteration of carbon, nitrogen, and phosphorus stoichiometric ratios in deep soil after afforestation. To examine the variations in stoichiometric ratios of soil elements with different vegetation types, restoration times, and soil depths, we collected soil samples from grassland, Caragana korshinskii shrubland, and Picea asperata forestland at different stand ages (10a, 25a, and 40a) in Xining City, which is located on the Loess Plateau. Our results showed that, at 25a, the carbon-to-nitrogen (C:N) and carbon-to-phosphorus (C:P) ratios were significantly higher in the grassland soil than under other vegetation types, whereas the nitrogen-to-phosphorus (N:P) ratio had no significant difference among the three vegetation types. At 40a, the ratios of soil C:N, C:P, and N:P in the shrubland were the highest. With the increasing of the restoration time, the ratios of soil C:N, C:P, and N:P in grassland with 25a became higher than for 40a or 10a. The ratios in the shrubland were highest at 40a, followed by 25a and then 10a, while the ratios in the forestland showed no significant difference. At 40a, the soil C:N, C:P, and N:P ratios of shrubland were highest at the soil depth of 40-100 cm. The soil C:N, C:P, and N:P ratios showed positive correlations with soil ammonium nitrogen and nitrate nitrogen, and the soil N:P ratios showed a negative correlation with soil available phosphorus. Plant diversity significantly influenced the soil stoichiometric ratio of the upper soil layer. In the upper soil layer (0-40 cm), species richness showed a positive correlation with soil C:N, C:P, and N:P ratios, and the Margalef index exhibited a positive correlation with soil C:N and C:P ratios. The results of this study indicate that the stoichiometric ratio and nutrient availability of Caragana korshinskii shrubland were the highest over time. Therefore, these findings can be served as a valuable reference for local revegetation and ecological restoration.