Erythromycin is one of the typical macrolides which is isolated by the Saccharopolyspora erythraea. It has been listed in WHO essential medicine for improvement of the efficiency of health system. In this study, magnetic iron nanoparticles were coated with cetyl as a non-polar functional group and characterized by various techniques such as infrared spectroscopy, thermal gravimetric analysis , scanning electron microscopy and vibrating sample magnetometer. The as-prepared nanoparticles were used to extract erythromycin from the milk samples. Separation was performed on a pentaflurophenyl column (150 × 2 mm, 3 μm) using a mobile phase consisting 70% acetonitrile and 30% ammonium acetate (10 mM, pH3.5) with a high performance liquid chromatography system coupled with tandem mass spectrometry. The separation was fast and completed in less than 5 min, under the optimized condition. Stable isotope of erythromycin was used as internal standard in the sample preparation and calibration curve. It was found that relative recovery of the method was 92.6%. The proposed method was convenient, and a quick preparation method was achieved using external magnetic field without centrifugation and filtration. The detection limit and coefficient of determination were 2.4 μg l-1 and R2 = 0.9983, respectively. The intra- and inter-day precisions of the proposed method in different levels of spiked sample were in the range of 5.6-8.5% and 8.4-12.5%, respectively.