Neutron stars are among the densest objects in the Universe. They have a radius of 10-20 km but carry a weight up to 2.5 times the mass of the Sun.
A neutron star is the collapsed core of a star. They are formed when the core pressure exceeds the Chandrasekhar limit of about 1.4 solar masses. The electron degeneracy pressure is exceeded which forces protons and electrons to combine to form neutrons.
In its dying phase, when a star with a core containing mainly iron exhausts all its fuel, it collapses under gravity and explodes as a supernova. The extreme high pressure causes protons and electrons to combine into neutrons forming a neutron star. The energy released in the process blows away the outer layers of the star.