Potatoes, like tomatoes, eggplants, tobacco and petunias, are members of the Nightshade family. A characteristic of these plants is that they produce alkaloids, chemical compounds that are extremely toxic in some forms, benign or medicinal in other forms. The nicotine in tobacco is a non-toxic alkaloid.
The alkaloids are concentrated in different parts of the plant in different species. The In potatoes, the tubers are relatively free of the toxins, except when the tubers turn green in reponse to light and begin to sprout (that’s why it’s always recommended to trim away green patches and sprouts on a potato before cooking). The foliage of tomato plants is high in toxins, but the fruits get spared.