Carbon nitride@Indium oxide (C3N4@In2O3) composite with quasi-shell–core structure was successfully prepared in this work. The photoinduced open circuit potential and current density results show that the C3N4@In2O3 composite with quasi-shell–core structure could provide the optimal photoelectrochemical cathodic protection capability for 304 stainless steel under visible light when the adding amount of C3N4 in the C3N4@In2O3 composite is 3wt%. The light absorption capability of the C3N4@In2O3 composite was enhanced due to the synergistic effect of heterojunction structure. According to the HRTEM images, photoinduced Volt–Ampere characteristic curves and electrochemical impedance spectra, the ultrathin coating layer of C3N4 on the surface of In2O3 helps to form a heterojunction electric field at the interface between C3N4 and In2O3, which enhances the separation efficiency of the photogenerated electron–hole pairs. Excessive C3N4 will decline the photoelectrochemical cathodic protection of this composite due to the lower intrinsic electronic mobility and the lower photoelectric conversion property of C3N4.