When machining workpieces with complicated and intricate shapes by wire electrical discharge machining, the workpiece height usually varies along a machining path. To ensure a stable and efficient machining, the machining parameters must be appropriately tuned based on the estimated workpiece height. Though an offline workpiece height estimation model can be established by traditional support vector regression with a satisfactory accuracy, the offline model is unable to cover all possible machining conditions. In this paper, least squares support vector machine is proposed to build up online a workpiece height estimation model. Due to the use of equality constraints in the formulation of least squares support vector machine, all data points are treated as support vectors, thus sparsity is lost as compared with traditional support vector machine. For online applications, a low computational load as well as a limited memory storage are required for an online algorithm. To meet the requirements of online workpiece height estimation, two measures are thus adopted. One is the use of a projection method which measures the relevance of a new data point with existing basic vectors by calculating its residue. The residue is used as criteria for admission of the new data point as a new member of the basic vector set. The other is the restriction on the size of the basic vector set. Removal of an insignificant basic vector is determined by its contribution to the model, which is measured by its coefficient in the model (or support value). Experimental results show that, by online learning, the estimation model can achieve an estimation error less than 2 mm at smooth parts of a workpiece. Based on the estimated workpiece height, proper machining parameters can be set and a stable machining can be achieved.