A gravitational binding energy is the minimum energy that must be added to a system for the system to cease being in a gravitationally bound state. A gravitationally bound system has a lower (i.e., more negative) gravitational potential energy than the sum of its parts — this is what keeps the system in accordance with the minimum total potential energy principle.
For a spherical mass of uniform density, the gravitational binding energy U is given by the formula
where G is the gravitational constant, M is the mass of the sphere, and R is its radius.
Assuming that the Earth is a uniform sphere (which is not correct, but is close enough to get an order-of-magnitude estimate) with M = 5.97 x 1024 kg and r = 6.37 x 106 m, U is 2.24 x 1032 J. This is roughly equal to one week of the Sun's total energy output. It is 37.5 MJ/kg, 60% of the absolute value of the potential energy per kilogram at the surface.
The actual depth-dependence of density, inferred from seismic travel times (see Adams–Williamson equation), is given in the Preliminary Reference Earth Model (PREM). Using this, the real gravitational binding energy of Earth can be calculated numerically as U = 2.487 x 1032 J.
According to the virial theorem, the gravitational binding energy of a star is about two times its internal thermal energy in order for hydrostatic equilibrium to be maintained. As the gas in a star becomes more relativistic, the gravitational binding energy required for hydrostatic equilibrium approaches zero and the star becomes unstable (highly sensitive to perturbations), which may lead to a supernova in high-mass stars due to strong radiation pressure or black holes in neutron stars.