Neutron stars are formed when a massive star, with a mass between about 1.4 and 3 times that of the Sun, exhausts its nuclear fuel and collapses under its own gravity. During the collapse, the core of the star compresses, and the protons and electrons combine to form neutrons, creating a dense neutron core. If the core’s mass is between about 1 and 3 solar masses, the neutron degeneracy pressure can halt the collapse, leaving behind a neutron star.
Neutron stars are incredibly dense, with a mass of about 1.4 to 3 times that of the Sun packed into a sphere with a diameter of only about 10 to 15 kilometers. This density is comparable to that of an atomic nucleus, making neutron stars the densest objects in the universe, apart from black holes.