Here, band gap-tunable oxygen-doped graphitic carbon nitride (g-C3N4) with outstanding “two-channel” photocatalytic H2O2 production ability was prepared via hydrothermal treatment assisted by dissolution–precipitation process. XRD, N2 adsorption, UV–Vis, Fourier-transform infrared spectra, SEM, electrochemical impedance spectra, XPS and photoluminescence were used to characterize the obtained catalysts. The photocatalytic H2O2 production ability of as-prepared catalyst was investigated. The results show that oxygen doping not only changes the morphology of catalyst, decreases the band gap energy and promotes the separation efficiency of photogenerated electrons and holes, but also tunes the CB and VB potentials. As-prepared oxygen-doped g-C3N4 displays a H2O2 concentration of 3.8[Formula: see text]mmol[Formula: see text]L[Formula: see text], more than 7.6 times higher than that of neat g-C3N4. Because of the shift of CB and VB potentials, not only the CB electrons of oxygen-doped g-C3N4 reduce O2 to form H2O2, but also the VB holes can oxidize OH− to form [Formula: see text]OH, which subsequently react with each other to form H2O2. Such “two-channel pathway” causes the remarkably promoted H2O2 production ability.