Graphitic carbon nitride (C3N4) has been identified as an optimal material for hydrogen peroxide (H2O2) photosynthesis, although its utility is hampered by a high photocarrier recombination rate. Herein, a novel carbon nitride material with a giant built-in electric field (BEF), Trz-CN, is synthesized through a hydrothermal-calcination tandem strategy. The giant BEF (4.8-fold) induced by the large dipole moment facilitated the efficient separation and directional migration of photogenerated carriers. Trz-CN exhibited an H2O2 production rate of 569.9 µmol·g-1·h-1 using O2 as feedstock under visible light (λ > 420 nm), marking an impressive 11.2-fold enhancement compared to bulk C3N4. Utilizing air instead of pure O2 as feedstock resulted in a trivial 1.6% decrease in the H2O2 generation by Trz-CN while maintaining a substantial production rate of 560.6 µmol·g-1·h-1. Notably, Trz-CN showcased a sterilization rate of 99.9% against Escherichia coli (E. coli) in natural seawater. Density functional theory (DFT) calculations revealed that incorporating a nitrogen-rich skeleton into the C3N4 enhanced its oxygen adsorption capacity and lowered the energy barrier for H2O2 formation. This leads to enhanced photocatalytic performance for H2O2 generation under ambient air conditions. Trz-CN provides a new exploratory idea for direct air synthesis of H2O2 and ballast water treatment.