BACKGROUND: Cholesterol is a critical component of the human body, particularly within the brain, where it plays an essential role in maintaining cellular structure and function. In addition, the blood lipid profile has been recognized as a significant factor influencing cognitive performance. However, the association between the ratio of total cholesterol (TC) to high-density lipoprotein cholesterol (HDL-C) and cognitive function remains unclear. METHODS: This community-based, cross-sectional study was conducted using data from middle-aged and older adults (aged ≥45 years) participating in the China Health and Retirement Longitudinal Study (CHARLS). The primary exposure of interest was the ratio of TC to HDL-C, while the main outcome was cognitive function, assessed using cognition scores. The association between the TC-HDL-C ratio and cognitive performance was examined using multiple linear regression analyses and restricted cubic spline modeling to assess potential nonlinear relationships. RESULTS: A total of 8,914 participants were included in the analysis. Within a certain range, a higher TC-HDL-C ratio was significantly associated with improved cognitive scores ( CONCLUSION: Our findings confirm a significant nonlinear relationship between the TC-HDL-C ratio and cognitive performance in middle-aged and elderly individuals, even after adjusting for sociodemographic factors. These results underscore the potential importance of maintaining an appropriate TC-HDL-C ratio to support cognitive health in aging populations.