BackgroundAdverse childhood experiences are critical factors in depression and cognitive decrease, but the effect of adverse childhood health experiences (ACHEs) on cognitive function and the role of depression have not been fully studied.MethodsData were taken from the China Health and Retirement Longitudinal Study (CHARLS) of 2014 and 2018. This study used indicators of situational memory ability and mental status to measure cognitive capacity. Besides analyzing the different types of ACHEs, scores for ACHEs were calculated to represent the severity of ACHEs. The Center for Epidemiologic Studies Depression Scale (CES-D) was used to assess depression. The analysis of this study employed two different analytical strategies in order to examine the mediated effects of depression. We used Sobel’s test and Baron and Kenny’s causal step approach, which utilized a generalized least squares regression model. Furthermore, a logistic regression model was used to evaluate the robustness of the Karlson-Holm-Breen (KHB) approach.ResultsIn this study, 6301 individuals who met the requirements of the study were included. We found that being confined to bed (ACHE3) (β=-0.3846, p = 0.022) in childhood had a negative impact on cognitive function. Similarly, ACHEs had a negative effect on cognitive function (β=-0.0819, p = 0.090). And after the depression had been introduced into the model, the regression coefficient of ACHEs on cognitive function was no longer significant (β=-0.0170, p = 0.727). The Sobel test showed that for ACHE3, the mediated proportion of the total effect of depression was 36.92%. While for ACHEs, the proportion of the mediated effect of depression was 70.11%. Finally, a robustness test of the mediating effect using the KHB method revealed that the mediating effect still existed. Further, based on different gender, age, and educational levels, the heterogeneity test indicated that the relationship between ACHEs and cognitive function and mediating effects of the depression were different as well as passing the robustness test of the interaction.ConclusionThe decline in cognition had been shown to be correlated with ACHEs and depression mediated this relationship. Positive interventions might help to improve cognitive performance in individuals suffering from ACHEs and depression.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12889-023-16169-7.