The majority of terrestrial biomass is wood, but the elemental composition of its potential consumers, xylophages, differs hugely from that of wood. This causes a severe nutritional imbalance. We studied the stoichiometric relationships of 11 elements (C, N, P, K, Ca, Mg, Fe, Zn, Mn, Cu, Na) in three species of pine-xylem-feeding insects, Stictoleptura rubra, Arhopalus rusticus (Coleoptera, Cerambycidae) and Chalcophora mariana (Coleoptera, Buprestidae), to elucidate their mechanisms of tissue growth and to match their life histories to their dietary constraints. These beetles do not differ from other Coleoptera in their absolute elemental compositions, which are approximately 1000 (N), 100 (P, Cu) and 50 (K, Na) times higher than in dead but undecayed pine wood. This discrepancy diminishes along the wood decay gradient, but the elemental concentrations remain higher by an order of magnitude in beetles than in highly decayed wood. Numerical simulation of the life history of S. rubra shows that feeding on nutrient-poor undecayed wood would extend its development time to implausible values, whereas feeding on highly decomposed wood (heavily infected with fungi) would barely balance its nutritional budget during the long development period of this species. The changes in stoichiometry indicate that the relative change in the nutrient levels in decaying wood cannot be attributed solely to carbon loss resulting from decomposer respiration: the action of fungi substantially enriches the decaying wood with nutritional elements imported from the outside of the system, making it a suitable food for wood-eating invertebrates.