Functionalized polyethyleneimines that are compatible with non-fullerene acceptors have been developed by protecting the reactive amine groups, leading to non-fullerene solar cells with high power conversion efficiency and enhanced thermal stability.