The second-generation instrument SPHERE, dedicated to high-contrast imaging, will soon be in operation on the European Very Large Telescope. Such an instrument relies on an extreme adaptive optics system coupled with a coronagraph that suppresses most of the diffracted stellar light. However, the coronagraph performance is strongly limited by quasi-static aberrations that create long-lived speckles in the scientific image plane, which can easily be mistaken for planets. The ultimate performance is thus limited by the unavoidable differential aberrations between the wave-front sensor and the scientific camera, which have to be estimated andcompensated for. In this paper, we use the COFFEE approach to measure and compensate for SPHERE's quasi-static aberrations. COFFEE (for COronagraphic Focal-plane wave-Front Estimation for Exoplanet detection), which consists in an extension of phase diversity to coronagraphic imaging, estimates the quasi-static aberrations, including the differential ones, using only two focal plane images recorded by the scientific camera. In this paper, we use coronagraphic images recorded from SPHERE's infrared detector IRDIS to estimate the aberrations upstream of the coronagraph, which are then compensated for using SPHERE's extreme adaptive optics loop SAXO. We first validate the ability of COFFEE to estimate high-order aberrations by estimating a calibrated influence function pattern introduced upstream of the coronagraph. We then use COFFEE in an original iterative compensation process to compensate for the estimated aberrations, leading to a contrast improvement by a factor that varies from 1.4 to 4.7 between 2l/D and 15l/D on IRDIS. The performance of the compensation process is also evaluated through simulations. An excellent match between experimental results and these simulations is found.