BackgroundBy continually monitoring end-tidal carbon dioxide concentrations, capnography can detect abnormal ventilation or apnoea early. This randomized, controlled study explored the effect of early intervention with capnography on the incidence of hypoxia in mildly obese patients undergoing sedation for esophagogastroduodenoscopy (EGD) and colonoscopy.MethodsThis is a single-center, randomized, single-blind, parallel-assignment, controlled trial. Mildly obese patients (28 kg/m2≤ BMI < 40 kg/m2) undergoing sedation for EGD and colonoscopy were randomly assigned to either the standard or capnography group. Standard cardiopulmonary monitoring equipment was used in both groups, and additional capnography was performed in the capnography group. In the event of inadequate alveolar ventilation during sedation, five interventions were administered in sequence (a-e) : a: increasing oxygen flow (5 L/min); b: a chin lift or jaw thrust maneuver; c: placement of the nasopharyngeal airway and chin lift; d: mask positive-pressure ventilation, and e: ventilator-assisted ventilation with tube insertion. The primary outcome was the incidence of hypoxia (SpO2< 90%, ≥ 10 s) in each group. The secondary outcomes included the incidence of severe hypoxia (SpO2≤ 85%), subclinical respiratory depression (90% ≤ SpO2< 95%), interventions, minimum SpO2during operation, patient satisfaction, endoscopist satisfaction, and other adverse events of anesthesia sedation.Results228 patients were included (capnography group = 112; standard group = 113; three patients were excluded) in this study. The incidence of hypoxia was significantly lower in the capnography group than in the standard group (13.4% vs. 30.1%,P= 0.002). Subclinical respiratory depression in the capnography group was higher than that of the standard group (30.4% vs. 17.7%,P= 0.026). There was only a 5.4% incidence of severe hypoxia in the capnography group compared with 14.2% in the standard group (P= 0.026). During sedation, 96 and 34 individuals in the capnography and standard groups, respectively, underwent the intervention. There was a statistically significant difference (P< 0.0001) in the number of the last intraoperative intervention between the two groups ( a:47 vs. 1, b:46 vs. 26, c:2 vs. 5, d:1 vs. 2, e:0 vs. 0 ). No significant differences were found between the two groups in terms of minimum SpO2during operation, patient satisfaction, or endoscopist satisfaction rating. There was no statistically significant difference in adverse events of anesthesia sedation between the two groups.ConclusionCapnography during sedation for EGD and colonoscopy allows for the detection of apnea and altered breathing patterns in mildly obese patients before SpO2is reduced. Effective intervention measures are given to patients within this time frame, which reduces the incidence of hypoxia and severe hypoxia in patients.Trial registrationEthical approval was granted by the Medical Ethics Committee (Chairperson Professor Tian Hui) of Qilu Hospital, Shandong University ((Ke) Lun Audit 2021 (186)) on 15/07/2021. The study was registered (https://www.chictr.org.cn) on 23/10/2021(ChiCTR2100052234). Designed and reported using CONSORT statements.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12871-023-02151-8.