While deficiencies in vitamin B6, folate, and vitamin B12 are linked to various human diseases, including anemia, depression, peripheral neuropathy, and cardiovascular disease (CVD), literature regarding the association between vitamin B6, folate, and vitamin B12 and erectile dysfunction (ED) is scarce. We aimed to determine the dietary intake of vitamin B6, folate, and vitamin B12 and ED in the United States population. We extracted data from the 2001-2004 cycles of the National Health and Nutrition Examination Survey (NHANES). Dietary intakes of B vitamins were collected based on one 24-hour dietary recall. The association between dietary intake of vitamin B6, folate, vitamin B12 and ED was examined using multivariate logistic regression models. A total of 3,875 participants were included for analysis, with 1,201 reporting ED and 2,894 not experiencing ED. The multivariable odds ratios (ORs) for the highest vs. lowest quartiles of vitamin B6 was 0.77 [95% confidence interval (CI): 0.60-0.99; P for trend =0.03] for the prevalence of ED. Subgroup analyses demonstrated a significant inverse association between dietary intake of vitamin B6, folate, vitamin B12 and the prevalence of ED among men aged ≤60 years, individuals of Mexican American and non-Hispanic White ethnicity, and those without a history of CVD, diabetes, hypertension, and high cholesterol. The consumption of dietary vitamin B6, folate, and vitamin B12 was significantly linked to decreased risks of ED among younger healthier men, suggesting a potential protective role of these nutrients against ED in United States adults.