The increasing demand for adsorbents used in environmental protection processes has made their cost increasingly high. To meet this demand, research is focused on the use of low-cost, locally available, biodegradable adsorbents, made from natural sources such as agricultural waste (olive pits, apple peelings, coffee grounds, etc.). This makes it possible to recover these wastes while contributing to environmental protection. The results obtained allowed us, on the one hand, to refine our understanding of the adsorption mechanism of walnut shells and activated carbon, and on the other hand to verify via the comparative study of walnut shells and activated carbon. Our work aimed to apply a process for treating water contaminated with methyl violet dye using adsorbents prepared from walnut shells (biomass, activated biomass, activated carbon and functionalized activated carbon).In this study, many effects were discussed, such as: the effect of the adsorbent, the mass of the activated carbon, the pH, the initial concentration, the functionalized activated carbon.The comparative study of adsorbents shows that the best adsorbent is activated biomass with removal efficiency equal to 77.71%.According to the results obtained, the pseudo second order model was the best, which describes the adsorption modeling, and for the isotherm, it was the Freundlich model.