Context. Wolf–Rayet (WR) stars of the WNh category contain a significant fraction of hydrogen at their surface. They can be hydrogen-burning, very massive stars or stars in a post-main sequence phase of evolution. Also, WNh stars are sometimes not included in population synthesis models. Aims. We aim to better characterise the properties of single WNh stars in the Galaxy and the Magellanic Clouds. In particular, we want to constrain their surface chemistry beyond the hydrogen content by determining the helium, carbon, and nitrogen surface abundances. Methods. We perform a spectroscopic analysis of 22 single WNh stars. We fit their ultraviolet and/or optical spectra using synthetic spectra computed with the code CMFGEN. We determine the main stellar parameters (temperature, luminosity, mass-loss rates) and the surface H, He, C, and N mass fractions. We investigate the ability of current evolutionary models to reproduce all parameters at the same time. Results. We find that all WNh stars show the signatures of CNO-cycle material at their surface: they are carbon-depleted and nitrogen-rich. A clear trend of higher nitrogen content at higher metallicity is observed, as expected. The amount of hydrogen (X) varies significantly from one star to another, independently of luminosity. Values of X larger than 0.4 are not exceptional. The majority of Galactic WNh stars can be explained by evolutionary models, provided sufficient fine-tuning of the input parameters of evolutionary calculations. At lower metallicity, most stars escape predictions from evolutionary models. This has been noted in the literature but constraints on the surface nitrogen content exacerbate this severe issue. Conclusions. Our study highlights the need to refine the treatment of WR stars in both stellar evolution and population synthesis models.