Lava tubes are a very common and important feature in mafic lava flows. The insulation provided by lava tubes allows molten lava to travel large distances from the vent with little cooling. This paper presents the first attempt to quantify the processes that control this cooling. The resulting thermal budget balances heat loss by (1) conduction, (2) convection of air in the wall rocks, (3) vaporization of rainwater, and (4) radiation out of skylights against (1) viscous dissipation, (2) latent heat released during crystallization, and (3) the cooling of the lava. When applied to the Waha'ula tube on Kilauea Volcano, Hawaii, this thermal budget reproduces the observed ∼1°C/km cooling of the lava inside the active tube. The thermal budget is also used to compare the insulating ability of hypothetical lava tubes in a continental flood basalt setting, on the ocean floor, Venus, the Moon, and Mars. This analysis demonstrates the large effect of rainfall and atmospheric convection, the importance of the volumetric flux of lava through the tube, and the overwhelming importance of compositional (i.e., rheological) differences. This work suggests that basaltic tube-fed flows several hundred kilometers long can be produced by eruptions with effusion rates of only a few tens of cubic meters per second. Thus even the longest lava flows observed in our solar system could have been produced by low to moderate effusion rate eruptions, if they were tube-fed.