Vitamin B12 plays a role in DNA methylation, influencing the 1-carbon cycle; However, its effect on colorectal cancer (CRC) mortality remains uncertain. This study assessed the relationship between vitamin B12 intake and all-cause and cancer-specific mortality among CRC patients. We analyzed data from the NHANES from 1999 to 2018, using multivariable Cox regression, competing risk model, Kaplan-Meier survival curves, and stratified analysis with interaction effects. The studied involved 4,554 cancer patients (mean age 65.8 years, 47.6% males). Results from multivariate Cox regression indicated that each additional 1 mcg/day of dietary vitamin B12 independently increased the risk of all-cause (HR, 1.07; 95% CI: 1.04-1.09, p < 0.001) and cancer-specific mortality (HR, 1.04; 95% CI, 1.02-1.06; p < 0.001). Kaplan-Meier curves indicated a higher risk of all-cause mortality with increased vitamin B12 intake (Log rank p = 0.01). Subgroup analysis suggested that higher vitamin B12 intake correlated with increased all-cause mortality risk, especially in individuals with higher protein (HR, 1.04; 95% CI, 1.02-1.06; p = 0.019) or carbohydrate intake (HR, 1.03; 95% CI, 1.01-1.05; p = 0.04). Thus, higher vitamin B12 intake correlates with increased all-cause and cancer-specific mortality in CRC patients, particularly those with higher protein or carbohydrate intake.