Magnetic carbonized polyaniline nanotube composite (Fe3O4@c-PANI) was synthesized via a self-assemble approach for the extraction and determination of three xanthene colorants including erythrosine B (EB), phloxine B (PB) and rhodamine B (RB). The scanning electron microscopy, transmission electron microscopy, Fourier transform infrared spectrometry, X-ray photoelectron spectroscopy and X-ray diffraction were adopted to confirm the successful synthesis of Fe3O4@c-PANI. When Fe3O4@c-PANI was applied for extracting three xanthene colorants, satisfactory extraction recoveries ranging from 89.48% to 94.15% were obtained with the relative standard deviation value of 1.09%–4.01%. Compared with Fe3O4, c-PANI and commercial adsorbents, Fe3O4@c-PANI achieved better retraction recovery for three colorants. Furthermore, adsorption kinetics and isotherms studies were analyzed to prove the adsorption mechanism of anionic and cationic colorants on Fe3O4@c-PANI. The graphite layers and pyrrole groups of the as-prepared composite can provide hydrophobic, π–π and hydrogen bonding interaction with xanthene colorants. Fe3O4 nanoparticles played dual-functional roles contributing to the separation and adsorption. Coupled with high performance liquid chromatography, the established magnetic solid phase extraction method was used for the analysis of beverage and fish samples.