Few studies have focused on the connection between dietary inflammatory index (DII) and cognitive function in obese people, despite the fact proved that both obesity and cognitive dysfunction are associated with chronic inflammation. Since DII can reflect the anti-inflammatory or pro-inflammatory potential of the diet, using the normal population as a reference we conducted a study in obese individuals to examine the relationship between DII and several cognitive functions in this population. Additionally, we investigate the mediating elements of this association. Higher DII scores were linked to lower Montreal cognitive assessment (MoCA) total scores, MoCA visuospatial function, MoCA naming, MoCA attention, and MoCA memory in the obese group, according to adjusted linear regression. Taking the tertile of DII score as a categorical variable substituted into a binary linear regression, the negative correlation between DII score and cognitive function score remains, as shown by the increasing incidence of mild cognitive impairment (MCI) as DII increases by one tertile. We discovered chained mediation effects in the mediation analysis between the DII score, erythrocyte membrane fatty acids and the overall MoCA score. We propose that in obese individuals, higher DII scores are linked to a deterioration in cognitive performance. Furthermore, the fatty acids in the erythrocyte membrane may mediate this action.