Carbon nitride (g-C 3 N 4 ) is synthesized by pyrolysis of urea, thiourea, dicyandiamide and melamine at the temperature ranging from 450 to 600 °C. The photocatalytic performance influenced by different precursors is extensively studied. The yields of carbon nitride pyrolyzed from dicyandiamide and melamine are much higher than that pyrolyzed from urea and thiourea. According to the NO removal efficiency measurement, the optimal fabrication temperature is obtained for four precursors. In addition, carbon nitride prepared from melamine under 500 °C (CNM-500) exhibits the best NO degradation performance compared to samples synthesized from other three precursors with the best fabrication conditions. Scanning electron microscopy, X-ray diffraction, transmission electron microscopy, and degradation ratio of NO x are adopted to study the morphology, crystal structure and photocatalytic degradation performance. UV-vis absorption spectroscopy and X-ray photoelectron spectroscopy are carried out to understand the origin of the excellent photocatalytic properties. The results show that the proper mole ratio of g-C 3 N 4 to melem (close to 1:1) is responsible for the highest photocatalytic performance of sample CNM-500. In addition, the specific surface area is another reason for different NO degradation performance. The present work provides new perspectives on selecting suitable precursors and proper synthesis temperature for carbon nitride preparation.