Developing nitrogen-enriched porous carbons using inexpensive and easily accessible biomass remains a great challenge in recent years. Herein, a series of nitrogen-doped porous carbons were prepared via tuning the pyrolysis process of raw rice husk (RH) or its derived char with melamine and KOH. The results demonstrated that raw biomass is more apt to react with melamine than biochar, facilitating the formation of carbon with ultrahigh nitrogen content. Furthermore, adding KOH into melamine would further promote the incorporation of nitrogen into carbon. The strong interaction between RH, melamine, and KOH during one-pot pyrolysis leads to a remarkable high nitrogen content of 17.71 at. % with up to 9.09 at. % pyridinic N in the resultant RH/K/M. Moreover, RH/K/M exhibited superior NOx conversion and excellent regeneration ability in selective catalytic reduction of NO with NH3 (NH3-SCR). The abundant pyridinic N groups enhanced the NOx and NH3 adsorption, as well as facilitated the oxidation of NO to NO2 and the activation of NH3 to NH2. This work provides an important guidance for large-scale preparation of N-enriched porous carbons from raw biomass and industrial application in the environment area.