More than three quarters of the baryonic content of the Universe resides in a highly diffuse state that is difficult to observe, with only a small fraction directly observed in galaxies and galaxy clusters. Censuses of the nearby Universe have used absorption line spectroscopy to observe these invisible baryons, but these measurements rely on large and uncertain corrections and are insensitive to the majority of the volume, and likely mass. Specifically, quasar spectroscopy is sensitive either to only the very trace amounts of Hydrogen that exists in the atomic state, or highly ionized and enriched gas in denser regions near galaxies. Sunyaev-Zeldovich analyses provide evidence of some of the gas in filamentary structures and studies of X-ray emission are most sensitive to gas near galaxy clusters. Here we report the direct measurement of the baryon content of the Universe using the dispersion of a sample of localized fast radio bursts (FRBs), thus utilizing an effect that measures the electron column density along each sight line and accounts for every ionised baryon. We augment the sample of published arcsecond-localized FRBs with a further four new localizations to host galaxies which have measured redshifts of 0.291, 0.118, 0.378 and 0.522, completing a sample sufficiently large to account for dispersion variations along the line of sight and in the host galaxy environment to derive a cosmic baryon density of $Omega_{b} = 0.051_{-0.025}^{+0.021} , h_{70}^{-1}$ (95% confidence). This independent measurement is consistent with Cosmic Microwave Background and Big Bang Nucleosynthesis values.