Recycling rare earth elements (REEs) contained in electronic waste is of utmost importance due to their ever-increasing use in the high-tech sector. In this context, the use of non-polluting techniques represents a real challenge for scientists. In this work, we demonstrated that a clean and energy-efficient process, diffusion dialysis, has great potential for the recovery of neodymium (Nd) and praseodymium (Pr), contained in the Nd-Fe-B magnets of end-of-life computer hard disk drives (HDDs). Four kinds of polymer membranes were prepared by blending cellulose triacetate (CTA) and polyethylenimine (PEI) with the addition of di-(2ethylhexyl) phosphoric acid (D2EHPA), tridodecylamine (TDDA), trioctylamine (TOA) or trioctylphosphine oxide (TOPO). The membranes were first characterized by several techniques such as water uptake, contact angle, ATR-FTIR, SEM, XRD and zeta potential. They were further implemented in diffusion dialysis experiments in which diluted HDDs leachates were used as feed solutions. The relevance of the diffusion dialysis process for the recovery of REEs was demonstrated as it was possible to extract up to 15% of the boron by spontaneous diffusion through the CTA / PEI / TOA membrane in 6 hours with a lab-scale cell operating in batch mode. All membranes were positively charged under the operating conditions and then, REEs (present mainly in the form of trivalent cations Nd 3+ and Pr 3+) were strongly rejected. A fairly good correlation was found between the membrane water uptake and boron transfer, with boric acid molecules passing more easily through the more hydrated membranes. The selectivity factor between boron and REEs resulted from the interplay between the membrane structure, its water uptake ability and surface charge. It was also found to be dependent on the leachate composition. The CTA / PEI / TDDA membrane was found to exhibit the greatest B / REE selectivity factors, with values reaching up to 3706 and 140 for Nd and Pr, respectively. The lower selectivity towards Pr was explained by the weaker Gibbs energy of hydration of Pr 3+ cations compared with Nd 3+ .