In this study we demonstrate that Mg addition improves properties of aluminum foams. To show this, the foaming behaviour of Al–5TiB2 composites containing varying magnesium content (0–3 wt%) was compared. The composites and foams were characterised using XRD, SEM and X-ray tomography. Higher expansions, uniform pore structure and better mechanical properties were achieved in the foams containing magnesium compared to the foams without magnesium. The reason for the improvement in the pore structure was attributed to a better stability caused by the addition of magnesium in Al–5TiB2 melt. Oxide formation due to magnesium addition partially contributes to the higher stability of foams. An improved structure as well as a higher microstructural strength due to the strengthening effect of magnesium are responsible for an increased strength in Mg-containing foams. © 2020 Elsevier B.V.