Polymeric carbon nitride (g-C3N4) is a promising 2D semiconducting photocatalyst for solar energy conversion applications. However, it suffers from poor performance due to sluggish charge carrier separation efficiency. Herein, we report a Na2H2PO4 treated g-C3N4/CuI (P-CN/CuI) photocatalysts with enhanced charge carrier separation at the interface of P-g-C3N4 and CuI. Double calcination of melamine at 650 °C caused a large redshift in the band tailing states and the energy bandgap, and treatment of g-C3N4 with Na2H2PO4 led to further improvement in the visible light absorption. The introduction of CuI into the P-CN matrix progressively improved the visible light absorption and charge carrier’s separation, as evident from the UV–vis and PL spectra. Due to the improved charge separation and light absorption properties, the P-CN/CuI photocatalyst produced ∼ 22 times higher hydrogen production than the bare g-C3N4. This work shows that non-metal doping and formation of a p-n heterojunction together could largely inhibit the charge carrier recombination in polymeric g-C3N4 for solar energy conversion applications.