First of all, let’s understand how a nuclear bomb works. Its core has fissile material. When detonating, a part of this material turns into energy (remember the famous Einstein equation?). Most of this energy is released as gamma rays, the most energetic of all. When this happens, immediately, the weapon itself disintegrates, because the energy of the gamma rays heats it to the point of turning it into plasma.
It happens inside the atmosphere, and it happens in space.
But let’s look at what happens in each scenario.
If the bomb explodes INSIDE THE ATMOSPHERE, not only will it receive that gamma ray energy. The air around it, too. Heating the air to plasma temperatures causes it to expand very quickly, like this:
And then, like this:
This hyperheated air pushes everything in its path at very high speed. This not only destroys buildings, vehicles, people and animals mechanically speaking, but also melts or incinerates them, thanks to the very high temperature. The air carries this temperature away.
But what if the bomb explodes in space?
If the bomb explodes OUT OF THE ATMOSPHERE, there is no air to convert the bomb’s energy into kinetic energy and heat. Therefore, the destruction is much less. Basically we would see the bomb explode (a huge flash), but that’s it. The bomb would become plasma (after all the gamma rays melt it), but then these rays would start to dissipate. After a few kilometers, they would no longer be fatal.
So, if you intend to blow up a nuclear bomb in space, park your ship at a safe distance. Because, if not, your ship (and you) WILL ALSO BECOME PLASMA, just by the effect of the gamma rays emitted by the bomb.
I recommend not blowing anything up … Especially because we are in a time of social confinement. Don’t leave home, even to explode nuclear bombs in space!