The electron transport layer (ETL) plays a crucial role in achieving high performance and stability of organic solar cells (OSCs). ETL materials suffering from low conductivity can impede charge collection and transport. Hyperbranched polymers display advantages of excellent film-forming property and facile preparation, which, however, often show low conductivity. In this work, we designed two hyperbranched polymers, HPDIN-B01 and HPDIN-B02, integrating the PDIN segments using two tribromomethylbenzene cores through a green and environmentally-friendly quaternization polymerization reaction. Both hyperbranched polymers possess outstanding alcohol solubility and suitable energy levels. Notably, HPDIN-B02 bearing three ethyl units on the benzene core exhibits a strong self-doping behavior as confirmed by electron spin resonance measurements, which is favorable for charge extraction and transport. As a result, when using HPDIN-B02 as ETL, PM6:L8-BO-based OSCs delivered a high power conversion efficiency (PCE) of 18.62%, and the performance is more insensitive to the thickness of the HPDIN-B02 film compared to that using HPDIN-B01. More importantly, HPDIN-B02-based devices also display remarkable durability under various conditions such as when stored in a glovebox, under thermal treatment, or under light illumination. This study demonstrates the great potential of the perylene diimide-based hyperbranched polymer as an efficient ETL for high-performing and stable OSCs.