Nitrogen and carbon are essential elements for life, and their relative abundances in planetary bodies are important for understanding planetary evolution and habitability. The high C/N ratio in the bulk silicate Earth (BSE) relative to chondrites has been difficult to explain through partitioning during core formation and outgassing from molten silicate. Here we propose a new model that may have released nitrogen from the metallic cores of accreting bodies during impacts with the early Earth. Experimental observations of melting in the Fe-N-C system via synchrotron X-ray radiography of samples in a Paris-Edinburgh press reveal that above the liquidus, iron-rich melt and nitrogen-rich liquid coexist at pressures up to at least 6 GPa. The combined effects of N-rich supercritical fluid lost to Earth’s atmosphere and/or space as well as N-depleted alloy equilibrating with the magma ocean on its way to the core would increase the BSE C/N ratio to match current estimates.