Hermit crabs molt on a regular basis as they grow but it is surprisingly easy to mistake a molting hermit crab for a dead hermit crab.
Molting or Dead
A molting crab appears quite limp and lifeless, and the body is often partway out of the shell. Sometimes, with very careful observation, you will be able to see small twitches from the hermit crab's body while it is molting, but otherwise, it can be very difficult to tell whether or not it is still alive. Plus, if your crab has buried themselves in the sand and you haven't seen them in a while, it is natural to start wondering if they are molting or if they have died where they buried themselves.
If you are not sure if your crab is molting or dead, how you handle the situation may make the difference between the life or death of your crab if they are indeed simply molting. The safest thing to do if you find your hermit crab in one of the situations mentioned above is to assume that they are just molting. If you disturb a molting hermit crab at a critical time during their molt while trying to determine if they are alive or not, the results can be disastrous.
Molting on the Surface
Since you are assuming your hermit crab is molting until proven otherwise, if your hermit crab appears lifeless and is in an isolation tank, leave them alone and watch to see what happens. If your hermit crab is in the main tank with other hermit crabs, especially if they are on the surface, cut the ends off of a two-liter pop bottle and sink it into the sand to surround the crab with a clear protective barrier.
Do not disturb a crab that is limply hanging out of their shell, but rather, protect them from other crabs. If they are molting, they should continue through the process if given the time to do so. If they have died, they will start to smell badly within a few days. A hermit crab may take up to two months to complete the entire molting process, so you will know far before that time whether or not they are still alive—and smaller crabs do not take nearly this long to complete the entire molting process.
If you find what appears to be a dead crab on the surface next to an empty shell, have a closer look to see if it is just an exoskeleton. If it is hollow and crumbles easily, it is an old exoskeleton, and your hermit crab has already molted and moved on to a new shell. Have a quick peek in a nearby shell, and you might find your molted crab hiding out in their new home.
Molting While Buried
A crab that is buried in their bedding is a bit trickier to care for or identify whether or not they are molting. Smooth the sand around their hiding spot and look for tracks to get an idea of whether or not they are coming up at night for food. Many crabs often disappear during the day but the tracks around the cage in the morning will let you know that they are still active. If it has been weeks since your crab buried itself and you still aren't sure whether or not your hermit crab is alive, you can carefully sweep off a bit of sand from around their hiding spot to check for a rotting smell.