Chitosan grafted polyaniline (Ch-g-PANI) loaded with different concentrations of cobalt ferrite magnetic (CoFM) nanoparticles (2, 5 and 10 wt%) to form (Ch-g-PANI/CoFM) nanocomposites were fabricated. X-ray diffraction (XRD), High-Resolution Transmission Electron Microscope (HRTEM), Scanning Electron Microscope (SEM), Energy-Dispersive X-ray (EDX), Fourier transform inferred (FT-IR), and Vibrating Sample Magnetometer (VSM) were carried out to investigate the structure, morphology, chemical composition, and magnetic properties of Ch-g-PANI and Ch-g-PANI/CoFM) nanocomposites. Adsorption performance of these prepared samples towards heavy metals (Pb2+, Cu2+, Fe3+, Cd2+, Li1+, Co2+, Al3+, Mn2+, Zn2+, Ni2+, Cr2+, and V2+) was investigated. The effects of CoFM NPs concentraion doped in grafted polymer, initial metal concentration, temperature, pH, and contact time on heavy metal removal efficiency were optimized. SEM revealed abundant pores for optimum sample that enhance the heavy metal removal efficiency. Competitive adsorption tests proved that Ch-g-PANI/CoFM5 NPs showed higher efficiency for tested heavy metals. The removal efficacy of optimum sample (Ch-g-PANI/CoFM5) reached maximum values 98, 95.3, 96, 99.2, 97, 99.9, 88, 94.4, 99.8, 93.4, 98.96, 93, and 93.9 % for Pb2+, Cu2+, Fe3+, Cd2+, Li1+, Co2+, Al3+, Mn2+, Zn2+, Ni2+, Cr2+, and V2+, respectively at 90 min(equilibrium time), the element ions concentration of 10 mg/L and pH range of 4–6 depending on the kind of metal ions. Freundlich model is the best isotherm model for the equilibrium data, suggesting the multilayer adsorption on the heterogeneous surface. The kinetic data specified that the pseudo-first-order model fitted the adsorption of heavy metal ions on Ch-g-PANI/CoFM5. Thermodynamic studies elucidated the feasible, spontaneous, random, and endothermic adsorption. From an economic viewpoint, the regeneration study implied that the optimal sample Ch-g-PANI/CoFM5 was efficiently recovered up to four successive cycles.