The use of the piezoelectric effect for regulating the separation and transportation of charge carriers in the artificial photosynthesis of H 2 O 2 has been established as a promising approach. However, an in-depth and comprehensive understanding of the piezoelectric effect on photocatalysis is still far from satisfactory. Herein, we have accurately modulated the molecular structure of graphitic carbon nitride (CN) to investigate the effect of piezoelectricity on photocatalytic H 2 O 2 production over CN. Our results show that the role of the piezoelectric effect in photocatalytic H 2 O 2 production over CN strongly depends on the molecular structure of CN. Specifically, for CN, CN modified by phosphorus (CN-P), oxygen-functionalized CN (CN-OF), and cyano-groupgrafted CN (CN-CA), the photocatalytic activity of CN, CN-P, and CN-OF is enhanced by approximately 1.40, 1.46, and 1.51 times due to the piezoelectric effect, respectively, while the photocatalytic activity of CN-CA is decreased by 6.0 times. To clarify and understand the key factors affecting piezo-photocatalysis activity, we employed density functional theory, photo-electrochemical measurements, and piezoresponse force microscopy measurements to explore active sites, piezoelectric polarization, and charge separation over molecular-functionalized CN. Our results reveal that the impact of the piezoelectric effect on photocatalytic H 2 O 2 production over CN results from the comprehensive influence of multiple factors. This work not only demonstrates that the molecular structure of CN determines whether the piezoelectric effect improves photocatalytic H 2 O 2 production over CN but also unveils the mechanism of the piezoelectric effect on photocatalytic H 2 O 2 production over CN.