The state of health and remaining useful life of lithium-ion batteries are key indicators for the normal operation of electrical devices. To address the problem of the capacity of lithium-ion batteries being difficult to measure online, in this paper, we propose an online method based on particle swarm optimization and support vector regression to estimation the state of health and remaining useful life. First, a novel health indicator is extracted from the discharge voltage to characterize the capacity of lithium-ion batteries. Then, based on the capacity degradation characteristics, support vector regression is used to predict the remaining useful life of these batteries, and particle swarm optimization is selected to optimize the parameters of the support vector regression, which effectively enhances the predictive performance of the model. Validated for the NASA battery aging dataset, when training with the first 40% of the dataset, the maximum error of the predicted remaining useful life was four cycles, and when training with the first 50% of the dataset, the maximum error of the predicted remaining useful life was only one cycle. When comparing to a deep neural network, support vector regression, long short-term memory algorithms and existing similar methods in the literature, the particle swarm optimization and support vector regression method can obtain more accurate prediction results.