Deficiency of vitamin B6 and vitamin B12, mostly in vegetarians, is found to be associated with depression and adverse neurological function. We investigated whether vitamin B6, B12, and folate have an effect on brain structure, especially among depressed people who follow a specific diet. The study sample comprised 9426 participants from the UK Biobank cohort with a mean age of 62.4 years. A generalized linear model controlling for age, sex, body mass index, ethnicity, town send deprivation index, educational qualification, smoking, and alcohol intake was used to test the association between study groups and structural brain volumes. Depression was more prevalent, and intake of vitamin B6 and B12 was lower among vegetarians, while non-vegetarians had a lower intake of folate. Overall, no significant association was observed between vitamin B6, B12, and folate intakes and both global and subcortical brain volumes among participants with depression. However, vitamin B12 intake was positively associated with right pallidum among non-depressed participants, and a significant interaction between vitamin B12 intake and depression status on the right pallidum was observed. Also, a significant interaction between folate intake and depression status on grey matter (GM) volume and left thalamus was observed. Upon diet stratification, folate intake is associated with total brain volume and GM volume among vegetarians with depression. Furthermore, no significant associations were observed for subcortical regions. Our findings suggest that dietary intake of vitamin B6 and B12 might have an effect on brain structure. Vegetarians, particularly those who suffer from depression may benefit from supplementing their diets with vitamins B6, B12, and folate to ensure brain health. Further studies, especially with a larger sample size and longitudinal design, are needed to confirm these findings.