Magnetic nanoparticles of magnetite (MNPs) with surfaces modified by biocompatible cationic polyelectrolytes polyethyleneimine (PEI) and chitosan (CS) are synthesized by the chemical coprecipitation method. The magnetic nanoparticles were characterized by transmission electron microscopy and measurements of zeta (ζ) potential. The initial MNPs exhibit shapes close to spherical, with an average size of 10 ± 3 nm. The immobilization of a polyelectrolyte on the surface of MNPs results in the formation of aggregates with an interconnected porous network (shell) around individual particles with average sizes of 12 ± 2 nm for Fe3O4@PEI and 15 ± 2 nm for Fe3O4@CS, respectively. The effect of various experimental parameters, such as pH, extraction time, amount of adsorbent, and initial concentration of the dye, on the adsorption and desorption of food azo dyes Allura Red AC (E129) and Black Brilliant BN (E151) has been thoroughly investigated. The results demonstrate that, under optimal conditions, the recovery of these dyes from aqueous solutions reaches 96–100%, at a concentration factor of 2.7 × 103 and adsorption capacities of 56 and 94 mg/g for Fe3O4@PEI, and 46 and 69 mg/g for Fe3O4@CS for E129 and E151, respectively. A comparison of the adsorption isotherms and kinetics of the process indicates that the Langmuir model and pseudo-second-order kinetics are preferable for describing the dye adsorption process. In the acidic and neutral pH ranges, electrostatic interactions primarily drive the adsorption process, while in the alkaline region, hydrogen bonding and hydrophobic interactions also play significant roles. The proposed adsorbents can be utilized for both the adsorption and preconcentration of the dyes in chemical analysis and the treatment of wastewaters for the dye removal. The preferred material for use is polyethyleneimine-modified nanomagnetite, which enables the adsorption and preconcentration of dyes across a wide pH range of 6–9. © Pleiades Publishing, Ltd. 2024.