Dinitrogen is produced commercially by the liquefaction and fractional distillation of air. 70% of air consists of nitrogen gas

In the laboratory, dinitrogen is prepared by treating an aqueous solution of ammonium chloride with sodium nitrite.

Very pure nitrogen can be obtained by the thermal decomposition of sodium or barium azide