BackgroundDiet quality is associated with psychobiological, psychological, biological, and physiological factors of individuals, and in the context of prolonged stress, such as the COVID-19 pandemic, it can lead to a worsening of the quality of food for undergraduates. This study aimed to analyze diet quality and associated factors in Brazilian undergraduates.MethodsData were collected from 4,799 undergraduate students from all Brazilian regions, from August 2020 to February 2021. The online questionnaire contained socioeconomic variables, the ESQUADA scale to assess diet quality, self-referred changes in weight, the Brazilian food insecurity scale (EBIA), sleep assessment and the perceived stress scale. Unconditional multiple logistic regression analysis was performed to study variables associated with poor and very poor diet quality.ResultsMost of participants presented a good diet quality (51.7%), while 9.8% had a poor or very poor diet quality and only 1.1% had an excellent diet quality. 58.2% of undergraduates reported to have an increase in weight during the pandemic and 74.3% of the students presented elevated stress during the pandemic. Logistic regressions showed students who gained weight during the pandemic presented the highest AOR = 1.56 (95% CI = 1.12–2.20) for poor or very poor diet quality. The elevated perceived stress was also associated with a higher AOR = 2.85 (95% CI = 1.71–4.74) for poor or very poor diet quality.ConclusionMost of the studied undergraduates presented a good diet quality. Nevertheless, poor/very poor diet quality was associated with higher perceived stress and weight gain. Our study indicated that policies should beaimed at the socioeconomically most vulnerable undergraduates, those in a situation of food and nutritional insecurity, high perceived stress, and who gained weight during the pandemic.