Objective To explore the protective effect of total flavonoids from Sauropus spatulifolius Beille on lung injury in mice infected with Mycoplasma pneumoniae (MP). Methods A total of 50 healthy BALB/c mice were selected and constructed into MP infection models by nasal drip of 20 μL MP suspension (1×10⁸ CCU/mL) for 3 times. Then they were randomly divided into a model group, an azithromycin group, and low-, medium-, and high-dose total flavonoids from Sauropus spatulifolius Beille groups, with 10 mice in each group. The mice in each group were given distilled water; 22.5 mg/(kg·d) azithromycin; and 20 mg/(kg·d), 35 mg/(kg·d), and 50 mg/(kg·d) total flavonoids from Sauropus spatulifolius Beille by gavage respectively, once a day for 12 consecutive days. Additionally, 10 healthy BALB/c mice were selected as the blank control group and given an equal volume of distilled water by gavage, once a day for 12 consecutive days. After 12 days of gavage, the physiological indicators (body temperature, body weight, lung coefficient, dry-wet ratio of lung tissue), lung function (peak expiratory flow [PEF], maximum voluntary ventilation [MVV], and lung resistance [RL]), lung injury scores, and the expression of key molecules in the Toll-like receptor 4 (TLR4)/nuclear factor-κB (NF-κB) signaling pathway in lung tissue (including relative expression levels of proteins of TLR4 and NF-κB and their mRNAs) were compared among the groups of mice. Results After 12 days of gavage, there were statistically significant overall differences among the six groups of mice in terms of body temperature, body weight, lung coefficient, dry-wet ratio of lung tissue, PEF, MVV, RL, lung injury scores, as well as the relative expression levels of TLR4 and NF-κB proteins and their mRNAs in lung tissue (all P<0.05). Compared with the blank control group, the model group showed increases in body temperature, lung coefficient, RL, lung injury score, as well as the relative expression levels of TLR4 and NF-κB proteins and their mRNAs in lung tissue, and decreases in body weight, dry-wet ratio of lung tissue, PEF, and MVV (all P<0.05). Compared with the model group, the azithromycin group and the low-, medium-, and high-dose total flavonoids from Sauropus spatulifolius Beille groups showed decreases in body temperature, lung coefficient, lung injury score, as well as the relative expression levels of TLR4 and NF-κB proteins and their mRNAs in lung tissue, and an increase in the dry-wet ratio of lung tissue (all P<0.05); the azithromycin group and the medium- and high-dose total flavonoids from Sauropus spatulifolius Beille groups showed increases in body weight and PEF (all P<0.05); the azithromycin group and the high-dose total flavonoids from Sauropus spatulifolius Beille group showed decreases in RL and increases in MVV (all P<0.05). Compared with the azithromycin group, the low-dose total flavonoids from Sauropus spatulifolius Beille group showed an increase in RL and a decrease in body weight (all P<0.05); the low- and medium-dose total flavonoids from Sauropus spatulifolius Beille groups showed increases in lung coefficient, lung injury score, as well as the relative expression levels of TLR4 and NF-κB proteins and their mRNAs in lung tissue, and decreases in PEF and MVV (all P<0.05); while there was no statistically significant difference in body temperature, body weight, lung coefficient, dry-wet ratio of lung tissue, PEF, MVV, RL, lung injury score, or the relative expression levels of TLR4 or NF-κB proteins and their mRNAs in lung tissue between the azithromycin group and the high-dose total flavonoids from Sauropus spatulifolius Beille group (all P>0.05). Compared with the high-dose total flavonoids from Sauropus spatulifolius Beille group, the low-dose total flavonoids from Sauropus spatulifolius Beille group showed an increase in RL and a decrease in body weight (all P<0.05); the low- and medium-dose total flavonoids from Sauropus spatulifolius Beille groups showed increases in lung coefficient and lung injury score, and decreases in PEF and MVV (all P<0.05). Compared with the medium-dose total flavonoids from Sauropus spatulifolius Beille group, the low-dose total flavonoids from Sauropus spatulifolius Beille group showed an increase in lung injury score (P<0.05). Conclusion The total flavonoids from Sauropus spatulifolius Beille can alleviate pulmonary inflammation and improve pneumonia symptoms by regulating the TLR4/NF-κB signaling pathway and inhibiting downstream NF-κB activation, with the high-dose group showing better therapeutic effects.