Anastomotic leaks (AL) and staple line leaks are a serious post-operative complication that can develop following bariatric surgery. The delay in the onset of symptoms following a leak usually results in reactive diagnostics and treatment, leading to increased patient morbidity and mortality, and a clinical and economic burden on both the patient and the hospital. Despite support in literature for pH as a biomarker for early detection of AL, the current methods of pH detection require significant clinician involvement and resources. Presented here is a polyaniline (PANI)-based pH sensor that can be connected inline to surgical drains to continuously monitor peritoneal secretion in real time for homeostatic changes in pH. During this study, the baseline peritoneal fluid pH was measured in two pigs using the PANI sensor and verified using a benchtop pH probe. The PANI sensor was then utilized to continuously monitor the changes in the pH of peritoneal effluent, as a gastric leak was simulated. The inline sensors were able to detect the resulting local changes in drainage pH within 10 min of leak induction. The successful implementation of this sensor in clinical practice can both enable high efficiency continuous monitoring of patient status and drastically decrease the time required to detect AL, thus potentially decreasing the clinical and economic burden incurred by gastric leaks.