Background and aimsCognitive impairment (CI) is a prevalent condition in patients with chronic kidney disease (CKD), who face an elevated risk of developing cognitive decline. The fundamental mechanism underlying CI is linked to chronic inflammation, which can be gauged by the Dietary Inflammatory Index (DII). The DII is categorized into anti-inflammatory diets with lower scores and pro-inflammatory diets with higher scores. Specifically, pro-inflammatory diets may contribute to chronic inflammation. However, the correlation between the inflammatory potential of diet and cognitive function in patients with CKD has not been explored. This study aims to investigate the connection between the inflammatory potential of diet and cognitive function in individuals with or without chronic kidney disease.MethodsData from the 2011–2012 and 2013–2014 National Health and Nutrition Examination Survey (NHANES) were utilized. Participants under the age of 60 or lacking DII, CI, CKD, and other essential data were excluded. DII was computed based on a 24-h dietary recall interview for each participant. Cognitive performance was evaluated using three cognitive tests: the Consortium to Establish a Registry for Alzheimer’s Disease (CERAD) test, the Animal Fluency Test (AFT), and the Digital Symbol Substitution Test (DSST). Logistic regression analysis and subgroup analysis were conducted to assess the independent relationship between DII score and CI in the CKD and non-CKD populations.ResultsThe study included a total of 2069 subjects, with CI prevalence ranging from 21.4 to 23.5%. Multiple regression models showed that after adjusting for all covariates of the three cognitive function tests, higher DII scores were significantly associated with increased risk of CI (CERAD OR = 1.18, 95% CI: 1.1 ~ 1.26, AFT OR = 1.15, 95% CI: 1.08 ~ 1.23, DSST OR = 1.19, 95% CI: 1.11 ~ 1.28). Subgroup analysis indicated that the effect of DII score on CI remained consistent in all subgroups (p > 0.05).ConclusionHigher DII scores were associated with an increased risk of cognitive impairment in people with or without CKD, suggesting that consuming a pro-inflammatory diet may contribute to the impairment of the cognitive function.