A powder X-ray diffraction study, combined with the magnetic susceptibility and electric transport measurements, was performed on a series of LnCoO3 perovskites (Ln = Y, Dy, Gd, Sm, Nd, Pr and La) over a temperature range 100 - 1000 K. A non-standard temperature dependence of the observed thermal expansion was modelled as a sum of three contributions: (1) Weighted sum of lattice expansions of the cobaltite in the diamagnetic low spin state and in the intermediate (IS) or high (HS) spin state. (2) An anomalous expansion due to the increasing population of excited (IS or HS) states of Co3+ ions at the course of the diamagnetic-paramagnetic transition. (3) An anomalous expansion due to excitations of Co3+ ions to another paramagnetic state accompanied by an insulator-metal transition. The anomalous expansion is governed by parameters that are found to vary linearly with the Ln ionic radius. In the case of the first magnetic transition it is the energy splitting E between the ground low spin state and the excited state, presumably the intermediate spin state. The energy splitting E, determined by a fit of magnetic susceptibility, decreases with temperature. The values of E determined for LaCoO3 and YCoO3 at T = 0 K as 164 K and 2875 K, respectively, fall to zero at T = 230 K for LaCoO3 and 860 K for YCoO3. The second anomalous expansion connected with a simultaneous magnetic and insulator-metal transition is characterized by its center at T = 535 K for LaCoO3 and 800 K for YCoO3. The change of the unit cell volume during each transition is independent on the Ln cation and is about 1% in both cases.