We often eat crabs, but in order for crabs to grow to a size where they are harvested by crab fishermen for sale as food, they need to get proper nutrition as well.
The three main types of crabs found in most of the world's oceans and seas are hermit crabs, fiddler crabs and sand crabs, and there is a slight difference in the answer to the question "What do Crabs Eat?" depending upon the type of crab.

What do Hermit Crabs Eat?

Hermit crabs are often kept in aquariums, where they eat algae as well as bits of food that fish and aquarium animals, such as snails, leave behind. Commercial hermit crab foods are available for crabs that are raised without other species present and therefore do not have access to food, but aquarium hermit crabs thrive on practically any food, from beef to eggs and vegetables. In the wild, hermit crabs crawl along beaches and shores to look for food in the sand, and they will eat anything from leaves to fruit and even wood. Hermit crabs are actually social animals that live in colonies, and they are called hermit crabs because they protect their soft bodies by living in shells that other sea animals discard, or that they obtain by killing other sea animals. However, when they kill animals for their shells, hermit crabs usually do not eat the animals themselves. For a more indepth look at What do Hermit Crabs Eat then please follow this link.

What do Fiddler Crabs Eat?

Fiddler crabs are sometimes sold for aquariums, but they are usually wild crabs, and they are known for the difference in size between their two claws. The smaller claw is the claw that fiddler crabs use for eating, and they use the larger ones for signaling their intentions to other crabs. Before a fiddler crab eats its meal of algae, fungus or other plant material, it sifts through the sandy or muddy waste from which it takes its food to remove any inedible particles. This helps keep its environment clean and aerated, and it leaves behind what it cannot eat in the form of small, round balls that it also uses to mark its territory. Fiddler crabs are occasionally sold as aquarium animals, but these crabs need to be kept in salt water even if they are advertised as fresh-water crabs. They are therefore not recommended for most aquarium hobbyists.

What do Sand Crabs Eat?

Sand crabs refer to quite a number of different species of ocean crab, all of which are known to burrow in the sand for food. Some of the food that sand crabs find while burrowing include smaller crabs, as well as baby turtles and carcasses of dead birds such as seagulls. Smaller crabs in turn feed upon mollusks and worms, as well as plankton and algae. Very few, if any, of the species that are commonly classified as sand crabs can be kept in aquariums, as they are saltwater creatures that require high temperatures to survive.

In general, crabs are scavengers, and as such they fulfill an important role in aquatic ecology by keeping their surroundings free of decomposing food that can cause bacteria to breed. Even larger crabs that feed on live prey aerate the sand in which they burrow, and thereby help to keep water and air circulating in their habitats.

A What Do They Eat? project.