Sulfonamide antibiotics (SAs) have been widely used as antibacterial drugs for the prevention and treatment of livestock and poultry diseases, but they seriously threaten human health because they can accumulate in humans. Therefore, it is highly important to develop methods for monitoring sulfonamide residues in aquaculture and food. In this research, based on the generation of porous carbon (PC) by the pyrolysis of sodium citrate, magnetic porous carbon (PC@Fe3O4) was synthesized by a solvothermal method and used as an adsorbent for the magnetic solid-phase extraction of SAs. The effects of the proportion of PC in PC@Fe3O4, adsorbent dosage, adsorption time, eluent type, extraction pH, salt concentration and eluent dosage on the extraction efficiency were systematically studied. The adsorption performance and behavior of PC@Fe3O4 on SAs were evaluated using adsorption kinetics and adsorption isotherms, and the adsorption mechanism was preliminarily discussed. Under optimal conditions, combined with capillary electrophoresis diode array detection, a sensitive detection method for SAs was developed. The proposed method can be used for the determination of six SAs in fishpond water and milk samples, with a linear range of 0.5–200 ng mL−1, detection limits of 0.24–0.34 ng mL−1, and spiked recoveries of 85.9–109.0 %.