By means of X-ray photoelectron spectroscopy (XPS), X-ray diffraction (XRD), open circuit potential (OCP) measurement and scanning electronic microscope (SEM), the in situ growth mechanism of the Mg–Al hydrotalcite film has been proposed. The composition and morphology of the films undergo a series of variations during the growth processes. The added Al compounds are a vital contribution to the formation of hydrotalcite. The film formation involves the dissolution of the AZ31 substrate, adsorption of the ions from solution, nucleation of the precursor, followed by the dissolution of Al 3+ , exchanging of OH − by CO 3 2− and growth of the hydrotalcite film.