Artificial photosynthesis offers a promising strategy to efficiently produce hydrogen peroxide (H2O2)-not only an essential industrial chemical but also a promising intermediate product in tumor therapy. However, the rapidly consumed dissolving O2, the competition between oxygen reduction reaction (ORR) and hydrogen evolution reaction (HER), and poor activity of water oxidation reaction (WOR) in the photocatalytic processes greatly restrict the efficiency of photocatalytic H2O2 production. In this study, we report a well-defined metal-free C5N2 photocatalyst for efficiently H2O2 production without sacrificial reagents and stabilizers both in normoxic and hypoxic systems. Experimental and computational investigations indicated that the strengthened delocalization of electrons by imine facilitated the formation of electronic structure matching H2O2 production both at the conduction band and valence band in thermodynamics, thus an efficient electron-hole separation and the realistic redox selectivity were successfully enabled. Under simulated solar irradiation, C5N2 achieved an apparent quantum efficiency of 15.4% at 420 nm together with a solar-to-chemical conversion efficiency of 0.55% for H2O2 synthesis, among the best H2O2 production photocatalysts in normoxic systems. More interestingly, due to the dual channels of H2O2 generation, C5N2 could efficiently remove hypoxia restriction and further induce more severe cell damage in photodynamic therapy (PDT). Our findings provided essential insights into the design and synthesis of the dual-channel H2O2 production photocatalysts at the molecular level and would pave more broad applications of photocatalytic H2O2 production.