We have modelled the phase diagram of magnetic shape memory alloys of the Heusler type by using the phenomenological Ginzburg–Landau theory. When fixing the parameters by realistic values taken from experiment we are able to reproduce most details of, for example, the phase diagram of Ni2+xMn1−xGa in the (T, x) plane. We present the results of ab initio calculations of the electronic and phonon properties of several ferromagnetic Heusler alloys, which allow one to characterize the structural changes associated with the martensitic instability leading to the modulated and tetragonal phases. From the ab initio investigations emerges a complex pattern of the interplay of magic valence electron per atom numbers (Hume–Rothery rules for magnetic ternary alloys), Fermi surface nesting and phonon instability. As the main result, we find that the driving force for structural transformations is considerably enhanced by the extremely low lying optical modes of Ni in the Ni-based Heusler alloys, which interfere with the acoustical modes enhancing phonon softening of the TA2 mode. In contrast, the ferromagnetic Co-based Heusler alloys show no tendency for phonon softening.