The main staples in the salamander's diet are insects, spiders and worms, but salamanders are opportunistic feeders and eat most animals that are appropriately sized. Larger salamanders are able to eat some fish, crabs, small mammals, and amphibians and water insects. Smaller salamanders often feed on beetles and their larvae, flies, earthworms, moths, spiders, grasshoppers, mites and springtails. In dire situations, salamanders may also eat other salamanders.
Glands in the tip and roof of the salamander's mouth excrete a sticky mucus that coats the tongue. Terrestrial salamanders are able to hunt by rapidly extending their sticky tongues to trap their prey. They're able to perform this maneuver in roughly 10 milliseconds.
Aquatic salamanders don't have the same long, sticky tongues. Instead, they grab their prey with their teeth and simultaneously shake their heads while snapping their jaws and pulling and pushing water in and out of their mouths. This utterly destroys the prey, making it easy to swallow and digest.
Pet salamanders are fed a diet of earthworms, slugs, wood lice and other small organisms. Because salamanders are nocturnal creatures, they should be fed at night when they're awake. Pet salamanders should always have plenty of water nearby, as they prefer to keep their skin moist.