Neutron stars form as remnants of massive stars after a supernova event. Unlike their progenitor star, neutron stars do not consist of a gaseous plasma. Rather, the intense gravitational attraction of the compact mass overcomes the electron degeneracy pressure and causes electron capture to occur within the star. The result is a compact ball of nearly pure neutron matter with sparse protons and electrons interspersed, filling a space several thousand times smaller than the progenitor star.
At the surface, the pressure is low enough that conventional nuclei, such as helium and iron, can exist independently of one another and are not crushed together due to the mutual Coulomb repulsion of their nuclei. At the core, the pressure is so great that this Coulomb repulsion cannot support individual nuclei, and some form of ultra-dense matter, such as the theorized quark–gluon plasma, should exist.
The presence of a small population of protons is essential to the formation of nuclear pasta. The nuclear attraction between protons and neutrons is greater than the nuclear attraction of two protons or two neutrons. Similar to how neutrons act to stabilize heavy nuclei of conventional atoms against the electric repulsion of the protons, the protons act to stabilize the pasta phases. The competition between the electric repulsion of the protons, the attractive force between nuclei, and the pressure at different depths in the star lead to the formation of nuclear pasta.