In this work, core/shell magnetic molecularly imprinted polymer nanoparticles were synthesized for extraction and pre‐concentration of valsartan from different samples and then it was measured with high‐performance liquid chromatography. For preparation of molecularly imprinted polymer nanoparticles, Fe3O4 nanoparticles were coated with tetraethyl orthosilicate and then functionalized with 3‐(trimethoxysilyl) propyl methacrylate. In the next step, molecularly imprinted polymer nanoparticles were synthesized under reflux and distillation conditions via polymerization of methacrylic acid, valsartan (as a template), azobisisobutyronitrile and ethylene glycol dimethacrylate as cross linking. The properties of molecularly imprinted polymer nanoparticle were investigated by FTIR spectroscopy, field emission scanning electron microscopy, and X‐ray diffraction. Box‐Behnken design with the aid of desirability function was used for optimizing the effect of variables such as the amounts of molecularly imprinted polymer nanoparticles, time of sonication, pH, and volume of methanol on the extraction percentage of valsartan. According to the obtained results, the affecting variables extraction condition were set as 10 mg of adsorbent, 16 min for sonication, pH = 5.5 and 0.6 mL methanol. The obtained linear response (r2 > 0.995) was in the range of 0.005–10 µg/mL with detection limit 0.0012 µg/mLand extraction recovery was in the range of 92–95% with standard deviation less than 6% (n = 3).