Mexican jumping beans (also known as frijoles saltarines in Spanish) are seed pods that have been inhabited by the larva of a small moth (Cydia deshaisiana) and are native to Mexico. The "bean" is usually tan to brown in color. It "jumps" when heated because the larva spasms in an attempt to roll the seed to a cooler environment to avoid dehydration and consequent death. They are from the shrub Sebastiania pavoniana, often also referred to as "jumping bean". However, they are not related to actual beans (legume plants), but rather to spurges. The beans are considered non-toxic but are not generally eaten.
After the moth-laid egg on the plant hatches, the larva eats away the inside of the bean (until it becomes hollow) and attaches itself to the inside of the bean with silk-like thread. The larva may live for months inside the bean with varying periods of dormancy. If the larva has adequate conditions of moisture and temperature, it will live long enough to go into a pupal stage. In the spring, the moth forces itself out of the bean through a round "trap door", leaving behind the pupal casing. After its metamorphosis, the small, silver and gray-colored moth lives for no more than a few days.
When the bean is abruptly warmed (by being held in the palm of the hand, for example) the larva twitches and spasms, pulling on the threads and causing the characteristic hop. Leaving the beans in a heated environment (such as direct sunlight) for an extended period of hours can easily kill them.
The beans become energetic when one holds them in the hand (out of the box) for a few minutes. The beans should also appear to be a very slight shade of green on the side. If one shakes a bean near one's ear and hears a rattle inside, the larva has either died or entered the pupal stage where its hardened shell makes a softer rattle.
Jumping beans are still available for sale in the United States. In the UK, they were a common novelty item in the 1950s.
A plastic toy under this name is manufactured and sold in packages of around 5-10. It resembles a medicine capsule and has a metal ball inside. When the surface on which the capsule was laid is tilted, the ball rolls to the other end and makes the capsule twitch. A group of several of these "beans" shaken gently will move around unpredictably.