The complex structure of organic dyes in industrial wastewater causes harm to the environment and human health. The elimination of such contaminants from wastewater has become a challenge for researchers. Out of the various techniques reported so far, adsorption is considered to be one of the most effective and low-cost treatment method to take away dyes from wastewater. In this study, a nanoscale magnetic adsorbent was prepared for removal of cationic dyes from wastewater by polymerization of pyrrole using ammonium persulfate as an oxidant in the presence of phytic acid and Fe3O4. The material was characterized by different techniques such as transmission electron microscopy, scanning electron microscopy, X-ray diffraction, and Fourier transform infrared spectroscopy. Influencing factors like temperature, adsorbent dosage, dye concentration, contact time, and pH have been optimized for potential application in the real field. Isotherm and kinetics studies indicated that the adsorption agreed well with the Langmuir adsorption isotherm and the pseudo-second-order model. The maximum adsorption capacity of the composite toward methylene blue and crystal violet was found to be 153.84 mg g-1 and 181.82 mg g-1, respectively. Thermodynamic parameters such as Delta G degrees, Delta H degrees, and Delta S degrees were evaluated.