It is well known that modifying graphitic carbon nitride (GCN) is an imperative strategy to improve its photocatalytic activity. In this study, Na-doped and K-doped graphitic carbon nitride (GCN-Na and GCN-K) were prepared via the simple thermal polymerization of a mixture of melamine and NaCl or KCl, respectively. The structure characterization showed that both Na + and K + intercalation could reduce the interlayer distance of GCN and introduce cyano defects in GCN, while K + apparently had a stronger influence on the structure variation of GCN. The chemical composition data showed that both Na + and K + could easily interact with GCN, while K-doping caused a greater change in the C/N ratio than Na-doping. Moreover, compared to GCN-Na-5 (5 represents weight ratio of alkali halide to melamine), the conduction and valence bands of GCN-K-5 both shifted upward based on the electronic and optical measurements. Consequently, GCN-K-5 yielded an H 2 evolution rate around 4 times higher than that of GCN-Na-5 under visible light irradiation (>420 nm). The cation size effect on GCN was proposed to be mainly responsible for the variation in the structure, optical and electronic properties of ion-doped GCNs, and hence the enhanced photocatalytic H 2 evolution. The current work can provide new insight into optimizing photocatalysts for enhanced photocatalytic performances.