Drinking water disinfection effectively prevents waterborne disease outbreaks but inevitably results in the formation of carcinogenic disinfection by-products (DBPs). Mitigating DBP formation without compromising microbial safety remains a critical challenge. Here we developed DISoptimizer, a water-quality-adaptive optimization framework designed to determine the optimal chlorine dose across heterogeneous water matrices, thereby maintaining a user-defined residual chlorine…