Dietary modification has been suggested as a viable path to mitigate climate change.This study explored the evolution of dietary structures in China’s megacities and quantified food-related carbon emissions using the carbon footprint method.Then,we developed a multi-objective optimization model to identify low-carbon dietary options that align with cultural preferences,economic feasibility,and nutritional requirements.We found that from 1992 to 2021,the total food consumption of residents in Beijing and Shanghai experienced a period of fluctuating decline and slow rise,respectively,with their dietary structures both shifting toward animal-based diets.Additionally,the significant increase in meat consumption led to increasing food carbon emissions in Beijing and Shanghai,with per capita emissions rising by 37.2%and 25.2%,respectively.According to the multi-objective optimization model,shifting towards reduced consumption of animal products,particularly meat,would align with culturally acceptable,economically feasible,and low carbon emission goals in Beijing and Shanghai,potentially leading to reductions of 92.14 t and 212.65 t in total food carbon emissions compared with the actual in 2021,respectively.This study enhances understanding of the changing dietary patterns in urban areas and their associated carbon emissions,and emphasizes the significance of optimizing diets as a key priority for advancing global sustainable development.