We show that the magnetic characteristics of Ta|CoFeB|MgO magnetic heterostructures are strongly influenced by doping the Ta underlayer with nitrogen. In particular, the saturation magnetization drops upon doping the Ta underlayer, suggesting that the doped underlayer acts as a boron diffusion barrier. In addition, the thickness of the magnetic dead layer decreases with increasing nitrogen doping. Surprisingly, the interface magnetic anisotropy increases to ∼1.8 erg/cm2 when an optimum amount of nitrogen is introduced into the Ta underlayer. These results show that nitrogen doped Ta serves as a good underlayer for spintronic applications including magnetic tunnel junctions and domain wall devices.