The coconut crab is an omnivore with a diet built mainly around plant material. Fallen fruit, nuts, seeds, and the soft pith of fallen trees make up most of what it eats. It also takes carrion, dead crustaceans, and the shed exoskeletons of other animals when it finds them, and will eat smaller crabs, including members of its own species.
The name reflects a real behavior, though a partly exaggerated one. The crab can work at a coconut with its claws, tearing at the fibrous husk and eventually reaching the flesh, but this takes considerable time and effort. In practice it often feeds on coconuts and other fruit that have already fallen and split. A keen sense of smell guides the search: its antennae carry odor-detecting structures that have converged on the shorter, blunter form seen in insects, and it can track the scent of rotting fruit, coconut, and meat over a distance.