A black hole could swallow the earth if one got close enough, but the actual effect a black hole would have on the planet would depend on its size. Very small black holes would have little impact if they collided with the earth, but some black holes are so large they could swallow the entire solar system.
The smallest types of black holes scientists theorize exist are called primordial black holes and were formed soon after the Big Bang. While many of these small black holes evaporated long ago, those weighing more than one billion tons could still be around. According to the New Scientist, if a black hole of that size hit the earth, it would be like a magnitude-four earthquake all around the globe. The effect would be noticeable, but it would cause little destruction.
Larger black holes can range in size from stellar black holes, which have a mass ranging from three to more than 10 times that of the sun, to supermassive black holes found in the center of galaxies. The largest known black hole has a mass equal to about 6.6 billion times that of the sun and could swallow the entire solar system if it got close enough. The likelihood of any of these larger black holes getting close enough to the earth to cause any problems, however, is extremely small.