Muscle mass is vital for physical activity and fundamental physiological processes supporting long-term health. While aging is inevitable, certain modifiable factors positively influence muscle preservation and overall well-being. However, the relationship between the consumption of ultra-processed foods (UPF) and muscle mass is not yet clear. This study included 7,173 men and nonpregnant women aged 20-59 years with valid 24-hour dietary recalls and accessible whole-body dual-energy x-ray absorptiometry (DXA) scans from NHANES 2011-2018. UPFs were identified through the NOVA classification system, and the percentage of energy derived from UPF consumption was evaluated in quintiles. Muscle mass measures were derived from DXA scans and quantified by the total and regional muscle mass index (MMI, kg/m²) and appendicular muscle mass index (AMMI, kg/m²). Multivariable-adjusted generalized linear regression models were applied to investigate the association between consumption of UPFs and muscle mass measures overall and by sociodemographic subgroups. The multivariable-adjusted differences of total MMI from the lowest to highest quintile of UPF consumption were 0 (reference), -0.03 (95% CI, -0.13, 0.07), -0.13 (95%CI, -0.24, -0.04), -0.12 (95% CI, -0.23, -0.01), and - 0.17 (95% CI, -0.27, -0.08) (P for trend < 0.001). Subtotal MMI followed a similar magnitude of associational pattern as total MMI. For trunk MMI, corresponding values from the lowest to highest quintiles of UPF consumption were 0 (reference), -0.02 (95% CI, -0.07, 0.02), -0.05 (95%CI, -0.11, 0.00), -0.07 (95% CI, -0.13, -0.01), and - 0.07 (95% CI, -0.12, -0.01). For AMMI, corresponding values from the lowest to highest quintiles of UPF consumption were 0 (reference), -0.004 (95% CI, -0.07, 0.06), -0.08 (95%CI, -0.14, -0.02), -0.05 (95% CI, -0.11, 0.02), and - 0.10 (95% CI, -0.16, -0.04) (All P for trend < 0.001). While most subgroups maintained similar overall patterns, heterogeneous findings were also observed. For example, the multivariable-adjusted differences in total MMI between the lowest and highest quantile of UPF consumption were - 0.19 (95% CI, -0.32, -0.06) for non-Hispanic Whites, 0.18 (95% CI, 0.01, 0.36) for non-Hispanic Blacks, -0.25 (95%CI, -0.45, -0.04) for Hispanics, -0.25 (95% CI, -0.51, 0.05) for non-Hispanic Asians and - 0.32 (95% CI, -0.75, 0.12) for others (P for interaction < 0.001). Higher consumption of UPFs was significantly associated with lower values of total and regional muscle mass. Specifically, comparing the highest quantile of UPF consumption to the lowest, total MMI decreased by 0.93%, trunk MMI decreased by 0.76%, and AMMI decreased by 1.25%. The differences in associational patterns between UPF consumption and muscle mass across sociodemographic subgroups require further investigation.