By means of a hybrid density functional, we comprehensively investigate the energetic, electronic, optical properties, and band edge alignments of two-dimensional (2D) CdS/g-C 3 N 4 heterostructures by considering the effect of biaxial strain and pH value, so as to improve the photocatalytic activity. The results reveal that a CdS monolayer weakly contacts with g-C 3 N 4 , forming a type II van der Waals (vdW) heterostructure. The narrow bandgap makes CdS/g-C 3 N 4 suitable for absorbing visible light and the induced built-in electric field between the interface promotes the effective separation of photogenerated carriers. Through applying the biaxial strain, the interface adhesion energy, bandgap, and band edge positions, in contrast with water, redox levels of CdS/g-C 3 N 4 can be obviously adjusted. Especially, the pH of electrolyte also significantly influences the photocatalytic performance of CdS/g-C 3 N 4 . When pH is smaller than 6.5, the band edge alignments of CdS/g-C 3 N 4 are thermodynamically beneficial for oxygen and hydrogen generation. Our findings offer a theoretical basis to develop g-C 3 N 4 -based water-splitting photocatalysts.