Background and aim: Neonatal brain monitoring is increasingly used due to reports of brain injury perioperatively. Little is known about the effect of sedatives (midazolam) and anesthetics (sevoflurane) on cerebral oxygenation (rScO2) and cerebral activity. This study aims to determine these effects in the perioperative period.Methods: This is an observational, prospective study in two tertiary pediatric surgical centers. All neonates with a congenital diaphragmatic hernia received perioperative cerebral oxygenation and activity measurements. Patients were stratified based on intraoperatively administrated medication: the sevoflurane group (continuous sevoflurane, bolus fentanyl, bolus rocuronium) and the midazolam group (continuous midazolam, continuous fentanyl, and continuous vecuronium).Results: Intraoperatively, rScO2 was higher in the sevoflurane compared to the midazolam group (84%, IQR 77–95 vs. 65%, IQR 59–76, p = < 0.001), fractional tissue oxygen extraction was lower (14%, IQR 5–21 vs. 31%, IQR 29–40, p = < 0.001), the duration of hypoxia was shorter (2%, IQR 0.4–9.6 vs. 38.6%, IQR 4.9–70, p = 0.023), and cerebral activity decreased more: slow delta: 2.16 vs. 4.35 μV2 (p = 0.0049), fast delta: 0.73 vs. 1.37 μV2 (p = < 0.001). In the first 30 min of the surgical procedure, a 3-fold increase in fast delta (10.48–31.22 μV2) and a 5-fold increase in gamma (1.42–7.58 μV2) were observed in the midazolam group.Conclusion: Sevoflurane-based anesthesia resulted in increased cerebral oxygenation and decreased cerebral activity, suggesting adequate anesthesia. Midazolam-based anesthesia in neonates with a more severe CDH led to alarmingly low rScO2 values, below hypoxia threshold, and increased values of EEG power during the first 30 min of surgery. This might indicate conscious experience of pain. Integrating population-pharmacokinetic models and multimodal neuromonitoring are needed for personalized pharmacotherapy in these vulnerable patients.Trial Registration: https://www.trialregister.nl/trial/6972, identifier: NL6972.