Synthesis of a metal-free carbon nitride (g-C 3 N 4 ) photocatalyst in the form of nitrogen-rich g-C 3−x N 4+x derivatives is desirable for efficient solar to hydrogen conversion and remains a challenging task to achieve. Herein we report the development of homogeneous sheets of nitrogen-rich graphitic carbon nitride samples from melamine by a solid−gas interface approach. Using this method, pure g-C 3 N 4 (CN), g-C 3−x N 4+x under ammonia flow (CN-NH 3 ) and g-C 3−x N 4+x under nitrogen flow (CN-N 2 ) are prepared. The g-C 3−x N 4+x (CN-NH 3 ) sample shows better surface conductivity, wide optical absorbance in the visible region, reduced recombination and high electron donor density, and higher performance toward photoelectrochemical hydrogen evolution (HER). The g-C 3−x N 4+x (CN-NH 3 ) generates a photocurrent of 2.06 μA cm −2 , which is 2.5 times higher than that of the pure g-C 3 N 4 (CN) sample (0.85 μA cm −2 ). It also shows higher photocatalytic water splitting ability compared to the CN and CN-N 2 samples, generating 634 μmol g −1 hydrogen without cocatalyst and 1163 μmol g −1 of hydrogen with Pt cocatalyst. Density functional calculations suggest that the progressive band gap reduction with the increase in the N-dopant percentage can be attributed to the gradual increase in the partial π-occupations, which can lead to a significant stabilization of the conduction band minima. The theoretical modeling, however, indicates a saturation in the band gap effect after 75% of N-dopant. The onset potential of g-C 3−x N 4+x for HER appears at η = 0.43 V in dark and η = 0.34 V vs Ag/AgCl under solar light illumination of 1 sun.