This study aimed to investigate dietary fiber (DF) intake with the prevalence of chronic obstructive pulmonary disease (COPD) in the middle-aged and elderly population through analysis of the National Health and Nutrition Examination Survey (NHANES) data. The study utilized data from 3 cycles of the NHANES database (2007-2012). The exposure variable was DF intake, and the outcome variable was COPD prevalence. Weighted logistic regression was utilized to construct relationship models between the 2 variables. Confounding factors were adjusted, and subgroup analysis was to explore the association of DF intake with COPD. Restricted cubic spline (RCS) analysis investigated the nonlinear relationship between DF intake and COPD. Finally, mediation analysis was performed to determine whether the influence of DF intake on COPD prevalence is mediated through the alteration of white blood cell (WBC) counts. This study included a total of 7301 eligible participants aged >40 years. The results of the study indicated that an increase in DF intake significantly reduced the prevalence of COPD (odds ratio: 0.98, 95% confidence interval: 0.96-0.99, p<0.001), and DF intake was correlated with lung function indicators (e.g., forced expiratory volume in 1 second). Stratified analysis revealed that an increased DF intake significantly reduced the risk of COPD in male individuals, middle-aged individuals (aged 40-59 years), those with a body mass index ≤30 kg/m2, individuals with a history of smoking, and alcohol consumers (p<0.05). Through RCS analysis exploring the nonlinear association between DF intake and COPD prevalence, the critical threshold for the impact of DF intake on COPD prevalence was 15.10 gm. When DF intake was ≥15.10 g/d, it effectively reduced the prevalence of COPD. Mediation analysis results indicated that the WBC count partially mediated the association between DF intake and COPD, with a mediation proportion of 9.89% (p=0.006). Increased DF intake was linked to decreased prevalence of COPD, particularly in men and middle-aged people. WBC counts may be an important pathway linking DF intake and COPD.