Heavy metal pollution in water is one of the most pressing global environmental problems. In this research, two kinds of phosphorus-modified walnut shell biochar gel beads (P@WSBGB) and ferromagnetic gel beads (P@FWSBGB) were prepared by an environmentally friendly method to solve this problem. The maximum adsorption capacities for Pb2+ were 197 mg g−1 for P@WSBGB and 180 mg g−1 for P@FWSBGB, and for Cd2+, they were 125 mg g−1 and 108 mg g−1, respectively. Although Fe3O4 loading reduced adsorption capacity by approximately 10 %, life cycle assessment(LCA) showed that P@FWSBGB had a lower environmental impact than P@WSBGB when adsorbing the same amount of 1 mg of Pb2+. This indicates that a reasonable load of Fe3O4 can reduce the environmental impact. Conversely, when adsorbing Cd2+, the result was the opposite, demonstrating that unreasonable loading increased the environmental impact. To ensure that Fe3O4 loading did not lead to increased environmental impacts, we further analyzed the data to determine the optimal Fe3O4 loading level. The optimal Fe3O4 loading was determined to be 12.5 % for Pb2+ adsorption and <12.5 % for Cd2+. The main adsorption mechanism is that the -COOH and -OH groups on the surface of biochar form complexes with Pb2+ and Cd2+. Ion exchange, electrostatic attraction, co-precipitation of phosphate, and physical adsorption also contribute to the removal of Pb2+ and Cd2+. In summary, this research solved the challenge of difficult recycling of biochar powder and provides new insights for the synthesis and condition optimization of magnetic adsorbents.