Cephalexin (CEX) antibiotic is a potential contaminant to the environment. Use of boron-doped diamond anode led to CEX mineralization. CEX molecule underwent several hydroxylation reactions before CO2. Growth inhibition of E. coli decreased after rupture of the β-lactam ring.