One challenge in aging research concerns identifying physiological parameters or biomarkers that can reflect the physical health of an animal and predict its lifespan. In C. elegans, a model organism widely used in aging research, motor deficits develop in old worms. Here we employed machine vision to quantify worm locomotion behavior throughout lifespan. We confirm that aging worms undergo a progressive decline in motor activity, beginning in early life. Importantly, the rate of motor activity decline rather than the absolute motor activity in the early-to-mid life of individual worms in an isogenic population inversely correlates with their lifespan, and thus may serve as a lifespan predictor. Long-lived mutant strains with deficits in insulin/IGF-1 signaling or food intake display a reduction in the rate of motor activity decline, suggesting that this parameter might also be used for across-strain comparison of healthspan. Our work identifies an endogenous physiological parameter for lifespan prediction and healthspan comparison.