Blue Crabs and Dungeness Crabs
The best way to hold a crab is to approach it from behind and place your finger on the center of its carapace to hold it steady. Then, slowly put your fingers around each claw directly to prevent it from pinching you.
Remember, although crabs can be aggressive, they are very small and weak. As long as you are holding them by the claws, then are unable to pinch you!
Watch this video demonstration:
Small Crabs or Rock Crabs
Small crabs or rock crabs are much less of a danger. Simply approach them from behind and grasp them on each side of their shell. You can also grab their hind legs which makes them unable to reach you with their claws.