Monitoring synthetic colorants in foods is important due to their potential toxicity and pathogenicity. We propose here a new and simple method for the extraction and determination of erythrosine B (ERT-B) in food samples. A composite of polydopamine-based molecularly imprinted polymers coating magnetic nanoparticles (Fe3O4@PDA@MIP) was synthesized using a green approach and exploited for the magnetic dispersive solid-phase extraction (MDSPE) of ERT-B. Fe3O4@PDA@MIP provides a rapid extraction of ERT-B, exhibiting good reusability and preconcentration ability. Moreover, the MIP showed a relatively good imprinting factor (3.0 ± 0.05), demonstrating excellent selectivity against patent blue (an interfering dye) and other food matrix components. The proposed MDSPE was coupled to colorimetric smartphone-based detection that allowed us to obtain similar performances of UV–Vis spectroscopy detection. The smartphone-based optical detection facilitated the determination of ERT-B in the 0.5–10 mg/L range, with a limit of detection of 0.04 mg/L. The developed method was successfully employed to determine ERT-B in food samples (juice, candy, and candied cherries) with good recovery values (82–97%).