A magnetar is a rapidly spinning, highly magnetic neutron star, which is the ultra-dense corpse of a supermassive star. A magnetar's magnetic field can be trillions of times the strength of Earth's. Most magnetars are quite young. They form when a supermassive star can no longer produce nuclear reactions in its core. The core collapses to form a ball that's up to twice the mass of the Sun, but no larger than a city. It is so dense that a chunk of its matter the size of a sugarcube weighs millions of tons. As the core collapses, it spins faster and faster. The magnetic field of the entire core is then compressed into the rotating neutron star, so it is extremely powerful.