Environmental context The consumption of repurposed antibiotics increased due to the management of COVID-19, which in turn led to their increased presence in wastewater and potential environmental effects. This change has created a greater need for their analysis and treatment in different environmental water. This work presents a safe, low-cost method for analysing and treating water samples to ensure their suitability for human and animal use. Rationale Certain antibiotics have been repurposed for the management of infected COVID-19 cases, because of their possible effect against the virus, and treatment of co-existing bacterial infection. The consumption of these antibiotics leads to their access to sewage, industrial and hospital effluents, then to environmental waters. This creates a need for the routine analysis and treatment of water resources. Methodology Detection and quantitation of three repurposed antibiotics: levofloxacin (LEVO), azithromycin (AZI) and ceftriaxone (CEF) were studied in different water samples using LC-MS/MS methods employing a C18 column and a mobile phase consisting of 80% acetonitrile/20% (0.1% formic acid in water) after solid phase extraction on Oasis HLB Prime cartridges. Real water samples were treated with synthesised graphitic carbon nitride (g-C3N4) to remove the three types of antibiotics from contaminated water under experimental conditions optimised by response surface methodology, using Box–Behnken experimental design. Results The analytical method was validated in the concentration range of 10–5000 ng mL–1 for the three drugs. The removal percentages were found to be 92.55, 98.48 and 99.10% for LEVO, AZI and CEF, respectively, using synthesised g-C3N4. Discussion The analytical method was used for the estimation of the three cited drugs before and after their removal. The method was assessed using ComplexGAPI as a greenness tool and the RGB 12 algorithm as a whiteness model. The method was applied for the analysis and treatment of real water samples before and after their treatment. It proved to be simple, low-cost and environmentally sustainable.