In this project, the in-situ formation of magnetic nanoparticles modified with pectin and acetamide was presented and used as a sorbent in the magnetic solid-phase extraction method. The synthesis of the magnetic sorbent was studied by various characterization methods. The sorbent was employed for the microextraction of four model analytes including methyl paraben, ethyl paraben, propyl paraben, and butyl paraben. The separation and measurement of the extracted compounds were done by high-performance liquid chromatography-ultraviolet detection. In order to achieve the best extraction condition, factors affecting the extraction efficiency were investigated and optimized using response surface methodology. In the obtained optimized condition, the following parameters were achieved: limits of detection: 0.16–0.28 µg/L, limits of quantification: 0.49–0.92 µg/L, and intra- and inter-day relative standard deviations: 1.2%–6.6% and 1.6%–4.8%, respectively. The linear dynamic ranges of the method for methyl paraben, ethyl paraben, butyl paraben, and propyl paraben were 1–200, 0.5–500, 1–500, and 1–500 µg/L, respectively. In order to investigate the effectiveness of the method, the proposed magnetic nanosorbent was used to measure the desired parabens in cosmetic samples. The results showed good accuracy and precision of the developed method for the determination of trace amounts of target analytes