Coal is a major contributor to the global emission of nitrogen oxides (NOx). The NOx formation during coal utilization typically derives from the thermal decomposition of N-containing compounds (e.g., pyrrolic groups). NH3 and HCN are common precursors of NOx from the decomposition of N-containing compounds. The existence of H2O has significant influences on the pyrrole decomposition and NOx formation. In this study, the effects of H2O on pyrrole pyrolysis to form NOx precursors HCN and NH3 are investigated using the density functional theory (DFT) method. The calculation results indicate that the presence of H2O can lead to the formation of both NH3 and HCN during pyrrole pyrolysis, while only HCN is formed in the absence of H2O. The initial interaction between pyrrole and H2O determines the N products. NH3 will be formed when H2O attacks the C2 position of pyrrole with its hydroxyl group. On the contrary, HCN will be generated instead of NH3 when H2O attacks the C3 position of pyrrole with its hydroxyl group. In addition, the DFT calculations clearly indicate that the formation of NH3 will be promoted by H2O, whereas the formation of HCN is inhibited.