In this study, the application of near‐infrared (NIR) spectroscopy for online monitoring of the Moluodan extraction process was investigated. Paeoniflorin, the main active component of Moluodan, was chosen as the quality index. Samples were partitioned into calibration and validation sets by random select and set partitioning based on joint X‐Y distances algorithm (SPXY), respectively. Wavelengths for modeling were selected by manual method and competitive adaptive reweighted sampling (Cars) algorithm. Particle swarm optimization–based least square support vector machines (PSO‐LS‐SVM) and partial least squares models were both established for quantitative analysis to determine the content of paeoniflorin online. At last, 8 models were obtained according to the combination of these algorithms and the SPXY‐Cars‐PSO‐LS‐SVM model had the best quantitative analysis performance compared with the other 7 models. Specifically, in the developed SPXY‐Cars‐PSO‐LS‐SVM model, the determination coefficients of the calibration
and validation
sets were 0.99 and 0.95, respectively, and the root mean square errors of the calibration and validation sets were 0.012 and 0.024 mg/mL, respectively, and the relative standard errors of the calibration and validation sets were 2.84% and 6.34%, respectively. These results suggested that the appropriate sample partition, wavelength selection, and regression analysis methods in this study, namely, the SPXY‐Cars‐PSO‐LS‐SVM algorithm combined with NIR spectroscopy, could be an effective and real‐time approach for online monitoring of the extraction process of Moluodan.