Carbon nitride (CN) is one of the most promising non-metal catalysts currently, but its photocatalytic activity is not ideal due to its poor carrier separation efficiency within molecules caused by its unique electronic structure. In order to improve its photocatalytic performance, N-doped g-C
3N
4(NCN) was firstly prepared by high temperature condensation method using urea and citric acid as raw materials. Then, the CoS
2-modified NCN composites (NCN/CoS
2) were successfully prepared by photodeposition. The introduction of CoS
2 effectively enhances the photogenerated carrier separation efficiency of carbon nitride. At the same time, N doping effectively regulates the band gap of carbon nitride and broadens the visible light response range of carbon nitride. The photocatalytic hydrogen production results show that under visible light irradiation (
λ > 420 nm), the NCN/10CoS
2 presents the best photocatalytic hydrogen production performance (73.8 μmol·g
−1·h
−1), which is 4.9 and 10.4 times higher than that of NCN (15.0 μmol·g
−1·h
−1) and g-C
3N
4/10CoS
2 (7.1 μmol·g
−1·h
−1), respectively.