In this study, a liquid chromatography-tandem mass spectrometry (LC-MS/MS) method based on immunomagnetic bead cleanup and isotope dilution was established for the simultaneous detection of four aflatoxins (aflatoxins B1, B2, G1, and G2) in feed and feedstuff. The samples were extracted with an acetonitrile–water mixture (84 + 16, v/v), purified using automatic immunomagnetic beads, and detected by LC-MS/MS. Under the optimal LC-MS/MS conditions, the four mycotoxins had a linear relationship in the concentration range of 0.5–50 µg/kg, and the correlation coefficients were all greater than 0.99. The limits of detection of the four aflatoxins ranged from 0.075–0.17 µg/kg, and the limits of quantification ranged from 0.25–0.5 µg/kg. The average spike recoveries of the four common feed and feedstuff matrices (corn, soybean meal, pig compound feed, and chicken compound feed) at three spiked levels (2, 10, and 50 µg/kg) ranged from 80.8–118.3 %, and the relative standard deviations (RSDs) were all less than 7.80 %. Thirty-two actual feed samples were analyzed for the four aflatoxins. Aflatoxin B1 was detected in nineteen samples (0.11–6.39 µg/kg); aflatoxin B2 was detected in four samples (0.12–0.43 µg/kg); aflatoxin G1 was detected in four samples (0.19–0.57 µg/kg), and aflatoxin G2 was not detected. The immunomagnetic beads cleanup system could automatically remove each of the four aflatoxins in feed and feedstuff and realize batch sample processing in 20 min. The established LC-MS/MS method has high accuracy and repeatability, and it can be used for the rapid and simultaneous determination of four aflatoxins in feed samples.