# What keeps a gas giant from falling in on itself?

Pulsar's answer is indeed correct, but let me expand a bit more.

## What happens when a gas giant shrinks?

A uniform mass will have a self gravitational potential of $$-\frac{3GM^2}{5R}$$. If we decrease its radius, its potential will decrease as well and the difference will be turned into thermal energy. Although gas giants and stars are not uniform mass balls, their gravitational binding energy is still proportional to $$\frac{GM^2}{R}$$, Thus if the radius decreases it will release energy, which will raise the temperature in return.

## What happens when the temperature increases?

Assuming the gas in those planets obey the ideal gas law $$PV=nRT$$ (where $$R$$ is not the radius but the molar gas constant $$R=8.314\,\text{J K}^{−1}\text{mol}^{-1}$$), it's obvious that when $$T$$ increases and $$V$$ decreases (due to the shrink in the previous section) $$P$$ must increase. Note that most real gases behave qualitatively like an ideal gas, so this is not a crazy assumption.

## So what is the big picture?

The planet shrinks a little bit, the potential difference turns into thermal energy and its temperature rises. The rise in temperature will cause the pressure to rise and prevent the planet from shrinking further (holding the planet in hydrostatic equilibrium). However, the planet also loses energy due to EM radiation as well, so it will continuously shrink and radiate. The process is called Kelvin–Helmholtz mechanism.

For instance, Jupiter is shrinking the tiny bit of $$2\,\text{cm}$$ each year. Although you might think this is really nothing, the amount of heat produced is similar to the total solar radiation it receives.

As Rob Jeffries has correctly pointed out, what ultimately keeps a gas giant from collapsing indefinitely is the electron degeneracy pressure. Eventually because of high pressure the hydrogen and other elements in the deep interior of the gas giant will undergo a phase transition to a metallic phase and will not compress any further.

Jupiter's gravity is balanced by the thermal pressure of its atmosphere: Jupiter is in hydrostatic equilibrium (or quasi-equilibrium: it slowly loses heat in the form of radiation).

Jupiter is still shrinking (slowly), but ultimately even this will be halted by electron degeneracy pressure. This is where the free electrons in the core become so dense that they are unable to (all) occupy low-energy quantum states because of the Pauli exclusion principle. In these circumstances, the ideal gas law does not apply; instead the pressure (due to the non-zero momentum of the electrons) becomes dependent only on the density of the gas and not its temperature. There are also many other complications associated with coulombic interactions in hydrogen/helium mixtures at high densities.

Thus, even though the planet continues to radiate away its residual heat, this cooling does not result in much further shrinkage because the internal pressure does not change much. If it were not for degeneracy pressure then ultimately, a gas giant would collapse.

At present, the core of Jupiter is in a partially degenerate state with the ratio of Fermi temperature to temperature $$T_F/T \sim 10$$ (e.g. Guillot 2005), which limits the rate at which it shrinks. Younger, hotter and larger, gas giant planets will more closely follow the ideal gas treatment given above and shrink more rapidly.