Objective To investigate the causal relationship between 25 dietary factors and Streptococcus pneumoniae pneumonia using Mendelian randomization (MR). Methods Causal associations were analyzed by two-way univariate versus multivariate MR, and all instrumental variables were obtained from a large GWAS database. Genetic variants associated with dietary factors were selected as exposure factors from the UK Biobank database. Streptococcus pneumoniae pneumonia was identified as an outcome factor, and all data for its instrumental variables were obtained from the FinnGen database. Five Mendelian randomization analyses were used, and they were dominated by inverse variance weighted (IVW). Multiplicity and heterogeneity of SNPs were assessed using the MR-Egger intercept term test, Cochran’s Q test, and leave-one-out method. Use the Bonferroni correction to correct the P value. In addition, multivariate MR was used to exclude the influence of confounding factors from education, smoking, and household income, and to observe the direct relationship between dietary factors and Streptococcus pneumoniae pneumonia. Results The UVMR results showed that dried fruit intake [OR (95%CI): 0.472 (0.245 - 0.912); P=0.025], white pasta intake [OR (95%CI): 0.072 (0.008 - 0.664); P=0.020], and cooked vegetable intake [OR (95%CI): 0.358 (0.141 - 0.907); P=0.030] were associated with a reduced risk of Streptococcus pneumoniae pneumonia. Inverse MR results showed that an increased risk of Streptococcus pneumoniae pneumonia increased skim milk intake [OR (95%CI): 1.005 (1.002 - 1.008); P=0.001], dried fruit intake [OR (95%CI): 1.007 (1.002 - 1.012); P=0.007] and fresh fruit intake [OR (95%CI): 1.004 (1.000 - 1.008); P=0.042]. All exposure data passed the heterogeneity test (Cochrane’s Q-test P>0.05) and no horizontal pleiotropy was detected. The leave-one-out method analysis demonstrates the robustness of the causal relationship. The multivariate results showed a significant causal relationship between the white flour diet [OR (95%CI): 0.181 (0.054 - 0.609); P=0.006] and Streptococcus pneumoniae pneumonia. The effects of white flour intake [OR (95%CI): 0.180 (0.053 - 0.614); P=0.006] as well as dried fruit intake [OR (95%CI): 0.436 (0.201 - 0.948); P=0.036] on Streptococcus pneumoniae pneumonia remained unchanged after controlling for education. The effect of white flour food intake on Streptococcus pneumoniae pneumonia remained significant after removing household income [OR (95%CI): 0.182 (0.054 - 0.615); P=0.006], cigarette exposure[OR (95%CI): 0.185 (0.055 - 0.628); P=0.007], and excluding all confounders[OR (95%CI): 0.185 (0.054 - 0.633); P=0.007], respectively. The P-values of the multivariate Cochran’s Q and Egger’s intercept test did not show statistical significance, indicating the absence of heterogeneity and horizontal pleiotropy. Conclusion Our study provides genetic evidence to support a causal relationship between dietary factors and Streptococcus pneumoniae pneumonia and excludes the influence of three major confounding factors. These findings have important implications for the prevention and management of Streptococcus pneumoniae pneumonia through diet.