||Purpose: The purpose of this paper is to examine the impact of urbanicity on rural–urban migrants' dietary diversity and nutrition intake and whether its effect differs across various urban environments of migrants. Design/methodology/approach: Using the individual- and time-invariant fixed effects (two-way FE) model and five-year panel data from the China Health and Nutrition Survey (CHNS), this paper estimates a linear and nonlinear relationship between urbanicity and nutrition. The paper also explores the spatial heterogeneity between rural–urban migrants and rural–suburban migrants. Dietary diversity, total energy intake and the shares of energy obtained from protein and fat, respectively, are used to measure rural–urban migrants' nutrition on both quality and quantity aspects. Findings: The study shows that rural–urban migrants have experienced access to more diverse, convenient and prepared foods, and the food variety consumed is positively associated with community urbanicity. Energy intake is positively and significantly affected by community urbanicity, and it also varies with per capita household income. The obvious inverse U-shaped relationship reveals that improving community urbanicity promotes an increase in the shares of energy obtained from protein and fat at a decreasing rate, until reaching the urbanicity index threshold of 66.69 and 54.26, respectively. Originality/value: This paper focuses on the nutritional status of rural–urban migrants, an important pillar for China's development, which is often neglected in the research. It examines the urbanicity and the nutrition of migrants in China, which provides a new perspective to understand the dietary and nutritional intake among migrants in the economic and social development. Moreover, the urbanicity index performs better at measuring urban feathers rather than the traditional rural/urban dichotomous classification.