Food security is an important guarantee for people's lives and national security, and digital transformation provides a new approach to improving the level of food security. Based on panel data from 30 provinces in China from 2007 to 2021, this paper empirically analyzes the impact of digital transformation on food security using fixed effects model, mediation model, moderation model, and spatial Durbin model. The research results show that: (1) digital transformation has a promoting effect on the level of food security, and there is regional heterogeneity in this promoting effect; (2) digital transformation has a mediating effect on the level of food security, which can improve the level of food security by promoting technological innovation, agricultural scale management, and marketization levels; (3) environmental regulations play a positive moderating role in the process of digital transformation promoting the level of food security; (4) there is a spatial spillover effect of digital transformation on the level of food security, which has a positive spillover effect on surrounding areas. Therefore, moving forward, it is imperative that we prioritize the digital transformation of the entire food industry chain, promote the coordinated development of digital industries in various regions, further improve the R&D innovation capability of digital technology, promote the integration of farmland to achieve large‐scale agricultural operation, and enhance the level of marketization, and at the same time improve environmental monitoring standards, fully tap the promoting effect of digital transformation on regional food security level. [EconLit Citations: Q16, Q18, R15].