The state of charge (SOC) of lithium batteries is an important parameter of battery management systems. We aim at the problem that the noise variance is fixed during the estimation of the battery state by the unscented Kalman filter (UKF), which leads to low estimation accuracy. Lithium battery SOC estimation based on the UKF and whale optimization algorithm (WOA) is proposed. The first WOA is used to identify the parameters of the battery model. WOA–UKF is used to estimate the SOC of the battery, in which the observed noise variance and process noise variance of the UKF are updated through the second WOA, thereby the estimation accuracy is improved. The experimental results verify the effectiveness of the improved method.