Niobium provides the basis for all superconducting radio frequency (SRF) cavities in use, however, hydrogen is readily absorbed by niobium during cavity fabrication and subsequent niobium hydride precipitation when cooled to cryogenic temperatures degrades its superconducting properties. In the last few years the addition of dopant elements such as nitrogen has been experimentally shown to significantly improve the quality factor of niobium SRF cavities. One of the contributors to Q degradation can be presence of hydrides; however, the underlying mechanisms associated with the kinetics of hydrogen and the thermodynamic stability of hydride precipitates in the presence of dopants are not well known. Using first-principles calculations, the effects of nitrogen on the energetic preference for hydrogen to occupy interstitial sites and hydride stability are examined. In particular, the presence of nitrogen significantly increased the energy barrier for hydrogen diffusion from one tetrahedral site to another interstitial site. Furthermore, the beta niobium hydride precipitate became energetically unstable upon addition of nitrogen in the niobium matrix. Through electronic density of states and valence charge transfer calculations, nitrogen showed a strong tendency to accumulate charge around itself, thereby decreasing the strength of covalent bonds between niobium and hydrogen atoms leading to a very unstable state for hydrogen and hydrides. These calculations show that the presence of nitrogen during processing plays a critical role in controlling hydride precipitation and subsequent SRF properties. © 2018 IOP Publishing Ltd.