This paper is included in the Special Publication entitled 'The physics of explosive volcanic eruptions', edited by J.S. Gilbert and R.S.J. Sparks. The physics of vesiculation, i.e. the process of bubble formation and evolution, controls the manner of volcanic eruptions. Vesiculation may lead to extreme rates of magma expansion and to explosive eruptions or, at the other extreme, to low rates and calm effusion of lava domes and flows. In this paper, we discuss the theory of the different stages of vesiculation and examine the results of relevant experimental studies. The following stages are discussed: (1) The development of supersaturation of volatiles in melts. Supersaturation may develop due to a decrease in equilibrium solubility following changes in ambient pressure or temperature or due to an increase in the magma volatile content (e.g. in response to crystallization of water-free or waterpoor mineral assemblages). (2) Bubble nucleation. The classical theory of homogeneous nucleation and some modern modifications, heterogeneous nucleation with emphasis on the nucleation of water bubbles in rhyolitic melts and the role of specific crystals as heterogeneous sites. (3) Bubble growth. The effect of dynamics of growth. (4) Bubble coalescence. The theory of coalescence of static foams, factors that may effect coalescence in expanding foams and shape relaxation following bubble coalescence.