The general form for density D=M/V. Applying this formula to the Earth, DE=ME/VE. So, if V is the volume of a planet, V/VE is the proportion of its volume in relation to Earth. If the planet is bigger than Earth, then V/VE>1 and compressing its mass into the same volume as the Earth would increase its density by the same factor. So the density would change to D.V/VE. There would be a decrease in density if V<VE. But D=M/V, so the change in density would simply be M/VE. This is of course the mass of the planet squeezed or expanded into Eath's volume.
The density of water is 1g/cc=1E12kg/km^3. The density of the planets is best shown using the density of water as the unit. Treating every planet as a perfect sphere and knowing the mean radius of each we can work out the volume and calculate the density.
||Density (compared to water)