The development of water splitting technology is severely impeded by the limited strategies for preparing efficient photocatalyst with optimal structure. Herein, a facile structure and doping engineering strategy is proposed to obtain the atomic-thin mesoporous graphite carbon nitride (g-C 3 N 4 ) nanosheets with a large specific surface area of 212.5 m 2 g −1 , an ultra-large pore volume of 1.55 cm 3 g −1 , high C and O contents of ∼51.4 and 4.8% via an acid-assisted exfoliation route without any hard templates. The theoretical calculation reveals that the introduction of additional C/O atoms into g-C 3 N 4 matrix would boost the charge transfer rate and charge separation efficiency due to the enhanced electronic polarization effect (Bader Charge) and shortened bond lengths. Additionally, the electronic conductivity is demonstrated to be enhanced due to the formation of delocalized π-bonding both experimentally and theoretically. The synergic contribution of textural and electronic features renders an excellent photoelectrochemical (PEC) performance with 50–60 times larger photocurrent in comparison with the pristine g-C 3 N 4 and high hydrogen evolution rates of 830.1 and 115.5 μmol g −1 h −1 under the solar- and visible-light irradiation, respectively. This in-situ exfoliation approach demonstrates a facile yet efficient method to synthesize highly porous carbon nitride materials with optimal structure and composition for efficient water splitting.