It's not density, it's mass. A mass of 1kg compressed to the density of the Sun's core would pull the Earth with just as much force as a 1kg ball of styrofoam.
Xkcd did a what if on a black hole moon (getting it to collapse into one may be impossible, but a black hole the mass of the moon is theoretically stable), and it has the same conclusion, except just slightly colder instead of slightly frozen. And by slightly, I mean almost imperceptible.
Just to add some formality to this, the original commenter might want to look up the shell theorem for classical mechanics and Birkhoff's theorem for general relativity.