Spiders are important natural enemies in agricultural ecosystems. The biodiversity and community characteristics of spider directly determine the quality of ecosystem services such as pest control in cropland. Cropland and its surrounding recovery habitats are important for spiders. We used trap method to examine species composition, species diversity, and functional characteristics of spider communities at three altitudes (871, 1360 and 1635 m) and three habitats (cropland, natural recovery grassland, artificial restoration woodland) in Chongli District, Zhangjiakou, Hebei Province, China. The results showed that diversity index of different habitats was significantly diffe-rent. The abundance of spiders in artificial restoration woodland was 124.3, which was significantly higher than that in natural recovery grassland (70.1) and cropland (38.6). Species richness of artificial restoration woodland (16.3) and natural recovery grassland (21.4) were not significantly different, but both were significantly higher than those of cropland (8.9). The Shannon diversity index of artificial restoration woodland (2.04) and natural recovery grassland (2.05) was not significantly different, and both were significantly higher than that of cropland (1.55). There were significant differences in community composition among all three habitats. Spider body length was positively correlated with spider hunting types. Large spiders tended to get food by hunting. Natural recovery grassland and cropland spiders were dominated by safari, and artificial restoration woodland with more web-forming spiders. Spiders at higher altitude were generally small. Both natural recovery grassland and artificial restoration woodland could increase spider diversity and played important roles in regional biodiversity protection. Spider community composition differentiated in different habitats, with the overall functional characteristics of spider communities being changed and some habitats being retained. The index of spider diversity of the two recovery habitats was higher than that of cropland habitats, with differences in the species composition of the two recovery habitats, both of which had the function of protecting endemic species. Our results were useful for the protection and restoration of spider biodiversity on cropland and regional scales.