In-situ generation of H2O2 and its efficient utilization in chemical oxidation for water pollution treatment has garnered increasing attention. However, dependency on sacrificial agents and low working pH range greatly impeded its practical application. In this study, we reported an efficient and stable in-situ H2O2 generation (382 μM g−1 h−1) at a variable pH range from acid to alkaline (pH 3–9) via a photocatalytic process over a covalent organic polymer (COP-TT) Based on a series of probe experiments using various electron and hole sacrificial agents, the reaction mechanism especially the contribution of oxygen reduction reaction (ORR) and water oxidation reaction (WOR) to H2O2 production was investigated. Importantly, the advantages of in-situ production and utilization of H2O2 were evaluated by the degradation efficiency of antibiotics in the visible light-assisted Fenton reaction and UV/H2O2 processes. Compared with UV/H2O2, a much higher sulfamethoxazole (SMX) degradation efficiency was obtained in the photo-Fenton process (51.2 % vs. 97.3 %). Moreover, according to electron spin resonance (ESR) analysis and radical quenching results, •OH was proven to be the major reactive oxygen species (ROS) responsible for efficient SMX degradation. Hence, this study provides a promising alternative for in situ generation and utilization of H2O2 for water purification.