Dietary patterns and some dietary components have been linked with dementia. We therefore performed a meta-analysis of available studies to determine whether there is an association between diet and risk of dementia. We included eligible articles and estimated risk ratio (RR) with 95 % confidence intervals (95 % CIs). Finally, there were 43 trials that met the inclusion standard. Some food intake was related with decrease of dementia, such as unsaturated fatty acids (RR: 0.84, 95 % CI: [0.74-0.95], P = 0.006), antioxidants (RR: 0.87, 95 % CI: [0.77-0.98], P = 0.026), vitamin B (RR: 0.72, 95 % CI: [0.54-0.96], P = 0.026), and the Mediterranean diet (MeDi) (RR: 0.69, 95 % CI: [0.57-0.84], P < 0.001). Some material intakes were related with increase of dementia, such as aluminum (RR: 2.24, 95 % CI: [1.49-3.37], P < 0.001), smoking (RR: 1.43, 95 % CI: [1.15-1.77], P = 0.001), and low levels of vitamin D (RR: 1.52, 95 % CI: [1.17-1.98], P = 0.002). The effect of some materials needs further investigation, such as fish (RR: 0.79, 95 % CI: [0.59-1.06], P = 0.113), vegetables and fruits (RR: 0.46, 95 % CI: [0.16-1.32], P = 0.149), and alcohol (RR: 0.74, 95 % CI: [0.55- 1.01], P = 0.056). Thus, the MeDi and higher consumption of unsaturated fatty acids, antioxidants, and B vitamins decrease the risk of dementia while smoking and higher consumption of aluminum increase the risk of dementia. Low levels of vitamin D were associated with cognitive decline. The effect of fish, vegetables, fruits, and alcohol needs further investigation. The findings will be of great significance to guide people to prevent dementia.