Abstract One of the main goals of volcano geodesy is to improve the understanding of how an increase in pressure related to magma accumulation causes ground deformation in order to evaluate volcanic unrest. The inversion methods used for this purpose rely on a parametrization of the shape of the crustal volume in which pressure changes due to magma inflow/outflow (the magma domain), to search for the optimal parameters that minimize the difference between model predicted and measured ground displacements. However, these methods assume a predefined shape of the magma domain, which limits their applicability. Here, we propose a new shape optimization framework that can invert these sources without such prior, formulating a reconstruction problem to infer the complete shape of the magma domain. First, we validate this approach using a synthetic test case and then apply it to observations of the Svartsengi volcanic system in Iceland.