Anthocyanins, as a type of polyphenolic compound, have been discovered to offer multiple health benefits to humans, including anti-aging and anti-inflammatory properties. This prospective cohort study aims to examine the relationship of dietary intake of anthocyanin with all-cause mortality and cardiovascular diseases mortality in the US. The aim of this research was to explore the possible correlation between anthocyanin consumption and the mortality rate from all causes as well as from cardiovascular disease. Based on the Public Access NHANES-linked National Death Index files up to December 31, 2019, we identified mortality status and heart disease-specific causes of death. A multivariate Cox regression analysis was employed to evaluate the effects of anthocyanin intake on mortality outcomes, generating hazard ratios and 95% confidence intervals, adjusting for various demographic characteristics, lifestyle factors, and comorbid conditions. Additionally, we utilized Kaplan-Meier survival curves, subgroup analyses. In different scenarios, dietary anthocyanin intake was assessed using restricted cubic spline models. A total of 11,959 participants completed the final cohort, averaging 47.12 years of age (SD ± 0.35). Following adjustments for multiple variables, an inverse relationship was identified between anthocyanin intake in the highest quartile and all causes mortality, yielding a hazard ratio (HR) of 0.68 (95% CI: 0.52–0.89). Similarly, elevated anthocyanin consumption was linked to a reduction in heart disease mortality, with HR of 0.61 (95% CI: 0.38–0.97). Additionally, dose–response curve revealed a consistent decrease in both all-cause and cardiovascular mortality with increasing anthocyanin intake. Further subgroup analyses revealed that elevated intake of anthocyanins was linked to decreased all-cause mortality in White individuals and males. Moreover, high anthocyanin intake was significantly correlated with reduced all-cause mortality irrespective of hypertension or hyperlipidemia status. Our research indicates that an appropriate dietary intake of anthocyanins is associated with a reduction in overall mortality rates. Furthermore, the findings reveal a substantial association between anthocyanin intake and decreased mortality from cardiovascular diseases, suggesting that anthocyanins may effectively lower the risk of cardiovascular-related deaths.