Earth’s volatile elements cannot be accounted for as mixtures of different chondrites, despite their clear chondritic heritage. Early-acting, but as yet unidentified, processes apparently fractionated volatile elements now contained by planets. Here we test the hypothesis that planetary-scale differentiation, namely core formation and primordial atmosphere degassing, set Earth’s distribution of N, S, and C. To this end, we report new metal-silicate partitioning experiments on N up to 26 GPa and 3400 K; the highest pressure and temperatures conditions yet explored. Our results highlight a strong, positive effect of pressure on nitrogen partitioning into cores. We apply our new experiments with literature data for S and C partitioning to a model that couples core formation with degassing into the primordial atmosphere, to demonstrate that volatile elements ratios for Earth, and potentially Mars and Venus, can be set by primordial differentiation under conditions that also satisfy their moderately siderophile element budgets.