The performance of perovskite solar cells with mesoscopic carbon electrodes is limited by inefficient charge transport and charge accumulation at interfaces. Now, by reacting hexamethylene diisocyanate with organic cations at the surface of perovskite grains and passivating defects, 23.2% efficiency can be achieved in small-area devices.