Modified g-C 3 N 4 samples (g-X, where X corresponds to the number of hours of acid treatment of the melamine) with outstanding photocatalytic performance were prepared by using hydrochloric acid-treated melamine as a precursor and calcining at 550 °C for 2 h. An x-ray diffractometer, field-emission scanning electron microscope, infrared spectrometer, N 2 adsorption-desorption test, x-ray photoelectron spectroscopy, and ultraviolet-visible diffuse-reflectance spectroscopy analysis were carried out to characterize the phase composition, microstructure, chemical structure, specific surface area (SSA), chemical states, elemental composition and optical properties of the samples, respectively. The photocatalytic performance of the samples was evaluated by degrading the Rhodamine B (RhB) aqueous solution. The results showed that the crystal structure and vibration bands of melamine changed due to the reaction with hydrochloric acid. The crystallinity and grain size of g-C 3 N 4 in g-X (X=1, 2, 4, 6, 8, 10) reduced, and the SSA values of g-X increased compared to that of the g-0 sample, which was synthesized from pristine melamine. The g-X samples exhibited excellent photocatalytic activity towards degradation of RhB compared to g-0. The photocatalytic activity of the g-X samples increased gradually as the acid treatment time of the melamine increased from 1 h to 2 h, and then decreased gradually with the extension of the acid treatment time. The rate constant (k) values of g-X are higher than that of g-0. g-2 presented the highest rate constant (k=0.052 min −1 ), which was 5.5 times higher than that of g-0. The improved photocatalytic activity of the g-X samples was attributed to the higher SSA value, the appearance of surface defects, the outstanding photocarrier separation efficiency and stronger light harvesting ability of g-X, with the last two factors being more significant. Acid treatment of melamine is helpful in the preparation of high performance g-C 3 N 4 photocatalyst, and the microstructure and photocatalytic performance of g-C 3 N 4 were affected significantly by the acid treatment time.