Over the last 20 years, supernovae have become a key tool to constrain the expansion history of the Universe through the construction of Hubble diagrams, using luminosity distances to supernovae belonging to the 'Ia' subtype. This technique was key for the discovery that the expansion of the Universe is now accelerating. We review the principle and difficulties of the measurements, the classification and diversity of supernovae, and the physics of explosion. We discuss the systematic uncertainties affecting the cosmological conclusions with some emphasis on photometric calibration. We describe the major supernova cosmology surveys, the presented analyses and their conclusions, together with the present status of the field. We conclude on the expectations for the near future.