The overactive bladder (OAB) is associated with obesity and inflammation. The weight-adjusted waist index (WWI) has emerged as a novel and more accurate measure of obesity compared to traditional indices, while the Dietary Inflammatory Index (DII) quantifies the inflammatory potential of one’s diet. However, the relationship between WWI, DII, and OAB remains unclear. This study aims to elucidate the association between WWI and OAB and to determine whether this relationship is mediated by dietary inflammation. Data from the National Health and Nutrition Examination Survey (NHANES) between 2005 and 2018, comprising 10,176 participants, were analyzed in this study. The association between WWI and OAB was examined using multivariate logistic regression models, smooth curve fitting, and subgroup analysis. Furthermore, the predictive capabilities of various anthropometric indices—including WWI, body roundness index (BRI), body mass index (BMI), waist circumference, body fat percentage (BF%), and weight—on OAB incidence were assessed using Receiver Operating Characteristic (ROC) curve analysis. Finally, a mediation analysis was conducted to explore whether the DII mediates the relationship between WWI and OAB. There was a significant positive association between WWI and OAB. After adjusting for covariates, for each unit increase in WWI, there was a 40% increase in the prevalence of OAB (OR 1.40, 95% CI 1.25–1.58, P < 0.001). This positive correlation persisted when WWI was categorized into quartiles. The dose–response curve showed a significant linear positive correlation between WWI and OAB. The correlation between WWI and OAB persisted in subgroup analysis. The ROC curve analysis revealed that WWI had a superior predictive capability compared to traditional obesity indices, with an area under the curve (AUC) of 0.661 (95% CI 0.648–0.674, all P < 0.001). The results of the mediation analysis showed that 5.02% of the association between WWI and OAB was mediated by DII (P = 0.016). Our findings suggest that individuals with higher WWI may have an increased risk of OAB. Additionally, an anti-inflammatory diet may be beneficial in preventing OAB. Given the cross-sectional nature of this study, we cannot establish a causal relationship. Future longitudinal studies are needed to validate this association and investigate the potential biological mechanisms underlying this relationship.