The American Heart Association (AHA) recently introduced the Life's Essential 8 (LE8) to improve cardiovascular health (CVH). However, the association between LE8 and the risk of prediabetes or diabetes is not yet fully understood. Consequently, this study aims to assess the association between CVH, as evaluated by LE8, and the risk of prediabetes and diabetes. This cross-sectional study encompassed 7,739 participants aged ≥20 years from the 2007-2018 National Health and Nutrition Examination Surveys (NHANES). The CVH of participants was evaluated using the LE8, combining four health behaviors and three health factors. Glucose metabolic status categories included normal glucose metabolism, prediabetes including isolated impaired fasting glucose, isolated impaired glucose tolerance, both IFG and IGT, and diabetes. The associations between CVH and prediabetes and diabetes were analyzed using logistic regression, linear regression, restricted cubic splines, and subgroup analyses. Among 7,739 participants, 1,949 had iIFG, 1,165 were diagnosed with iIGT, 799 were IFG+IGT, and 537 were diagnosed with diabetes. After multivariable adjustments, CVH scores were inversely associated with prediabetes and diabetes, with the most robust inverse association observed between IFG+IGT and CVH across all prediabetes subgroups. Of all CVH components not directly in the causal pathway, body mass index (BMI) had the most robust associations with prediabetes and diabetes. Subgroup analyses indicated that the negative correlation between CVH and prediabetes was stronger among those with university or higher education. CVH, as defined by LE8, showed a significant negative association with prediabetes and diabetes.