Photocatalytic H2O2 production with H2O and O2 as resources is a promising technique. Herein, a g-C3N4@CdS (CN@CdS) Z-scheme heterojunction is prepared for photocatalytic H2O2 production with a rate of 167.5 μmol/h, which is 5.43 and 5.15 times higher than that of pure g-C3N4 and pure CdS. Photoelectronic characterization results reveal the existence of a strong built-in electric field between CdS and g-C3N4, which significantly facilitates the separation of photogenerated carriers and preserves the strong redox capacity. Density functional theory (DFT) calculations show that CN@CdS displays lower O2 adsorption energy and the H2O2 is more readily formed. This work provides a novel strategy for the design of photocatalysts with excellent H2O2 evolution efficiency.