ABSTRACT We present a novel method to retrieve the chemical structure of galaxies using integral field spectroscopy data through the stellar Metallicity Distribution Function (MDF). This is the probability distribution of observing stellar populations having a metallicity Z. We apply this method to a set of 550 galaxies from the CALIFA survey. We present the behaviour of the MDF as a function of the morphology, the stellar mass, and the radial distance. We use the stellar metallicity radial profiles retrieved as the first moment of the MDF, as an internal test for our method. The gradients in these radial profiles are consistent with the known trends: they are negative in massive early-type galaxies and tend to positive values in less massive late-type ones. We find that these radial profiles may not convey the complex chemical structure of some galaxy types. Overall, low mass galaxies (log M⋆/M⊙ ≤ 10) have broad MDFs ($\sigma _Z\sim 1.0\,$ dex), with unclear dependence on their morphology. However this result is likely affected by under-represented bins in our sample. On the other hand, massive galaxies (log M⋆/M⊙ ≥ 11) have systematically narrower MDFs ($\sigma _Z\le 0.2\,$ dex). We find a clear trend whereby the MDFs at rk/Re > 1.5 have large variance. This result is consistent with sparse SFHs in medium/low stellar density regions. We further find there are multimodal MDFs in the outskirts ($\sim 18\,$ per cent) and the central regions ($\sim 40\,$ per cent) of galaxies. This behaviour is linked to a fast chemical enrichment during early stages of the SFH, along with the posterior formation of a metal-poor stellar population.