How would a nuclear explosion in space differ from on the earth?

Yes, it would change it quite a bit.

For one thing, you have pretty much no blast wave, because the blast wave requires a gas (or solid; in which case it becomes an earthquake or seismic wave) medium to propagate. Instead, the only gas (or plasma, but close enough in these circumstances) that's available is just the very small amount generated by ionizing the bomb components and explosive fuel. This gas would shoot out in all directions at some speed of around 2000 km/s for a pure fission bomb, and maybe over 13 000 km/s for a fusion bomb (that's roughly 5% of light speed! And what makes fusion charges and fuels attractive as potential interstellar flight propellants; c.f. Enzmann starship). Hence it is reduced virtually instantly to such a low density as to not really have much effect on anything not very close (i.e. within 100 m or less) to the bomb.

But that doesn't mean the explosion would be without consequence. You see, when the blast wave is generated in an atmosphere, the great majority of it is actually fueled not by the direct pushing power of the expanding bomb gas, but rather by the radiation - mostly in the form of X-rays and hard prompt gamma - generated in the burst, being absorbed by the atmosphere and hyperheating it, generating much more pushing gas indirectly. Radiation is, in fact, the vast majority of energy released. This radiation would still be more than good enough to vaporize or mangle spacecraft at distance, and at greater distances easily fatal biological organisms - distances actually considerably farther than on Earth! This radiation would be emitted pretty much as an instantaneous, singular flash. A small amount would be visible light, so anyone looking in that direction would probably see something reminiscent of an extreme strobe pulse, followed by expanding puffs of vapor if it was lobbed at, say, a fleet of ships close together.

How much farther? Suppose we take a 60-terajoule bomb, which is about the size of the one used on Hiroshima, though a modern weapon would be more like 600 terajoules. You can get the radiation intensity by dividing this over a spherical area of suitable radius, i.e. 4pir^2. At a distance of 1 km, you can find the radiation intensity from the 60 TJ bomb is about 4.8 megajoules per square meter, about a kilogram of TNT striking that square meter area. This is enough to cause substantial damage to pretty much any material and would instantly evaporate and disintegrate a human body completely, or at least turn it to warm mush (as only a fraction would actually be absorbed). At 100 km, we still have 480 joules per square meter, which, given that a human body is already about a square meter of fronting area, would result in a fatal dose - about 7 grays, just at the lethal level, for an average mass human (65 kg). That's actually quite surprising, because 100 km from Hiroshima would've been perfectly safe on Earth at least unless and until fallout began to arrive, because virtually all that radiation got absorbed by the atmosphere to generate the blast wave. To get to a level under the threshold for acute radiation poisoning (about 1 Gy), you would have to be as far out as 280 km.

In this regard, nuclear weapons in space would be extremely potent anti-personnel weapons (and, to some extent, anti-electronics, because that intense ionizing flux would scramble many circuits) but much less potent anti-materiel weapons.

/r/askscience Thread