If you squeeze any object tight enough, it becomes a Black Hole. The critical size at which this happens is called the Schwarzschild Radius. Once an object is compressed smaller than this radius, not even light can escape its gravity.
The formula is elegantly simple:
$$R_s = \frac{2GM}{c^2}$$
Where $G$ is the gravitational constant, $M$ is the mass of the object, and $c$ is the speed of light.Here is a Python script to calculate how small you’d have to crush Earth to turn it into a black hole: