Environmentally sustainable diets are attracting increasing attention, but the environmental impact of diets with different income residents is still poorly understood. Based on the environmental footprint method, we explored the environmental impact of food consumption in China from 2000 to 2020, and used the Logarithmic Mean Divisia Index (LMDI) model to investigate its driving factors. Furthermore, we constructed a multi-objective optimization model, incorporating the affordability indicator, to optimize a healthy diet pattern. The results show that: (1) The food diversity index (FDI) was directly proportional to income, and geographically, the FDIs of economically developed provinces were higher than that of economically developing provinces. (2) The environmental footprint caused by food consumption was gradually increasing, with 60 % of the carbon footprint of low-income residents coming from grain and pork. (3) Dietary affordability was a major factor in increasing environmental footprint. High-income residents had greater access to milk, meat, etc., which had a greater negative environmental impact. We put forward suggestions on dietary optimization and affordability for different income residents, with a view to achieving nutritional and healthy diets of Chinese while generating minimum resource and environmental load, and promoting the transformation of the agro-food system.