Animals construct and inhabit nests that can exhibit dramatic intra- and interspecific variation due to differences in behaviour, the biotic and abiotic environment, and evolutionary history. In ants, variation in nest architecture reflects both differences in ecology and in the collective behaviour of the colonies that live in the nests. Each component of the nest (such as depth, and the number, size and connectivity of chambers) reflects selective pressures for different functions, or structural constraints that are imposed by the environment or evolutionary history. To determine potential drivers of nest structure variation in subterranean nests, we performed a meta-analysis of measures of published ant nests to compare different structural elements within and across species. We complemented this survey with 42 nest casts of two closely related species. We quantified nest features that can potentially impact ant foraging behaviour and examined whether phylogeny or foraging strategy are better explanatory variables for the variation we observed. We found that foraging strategy better explained nest features than evolutionary history. Our work reveals the importance of ecology in shaping nest structure and provides an important foundation for future investigations into the selective pressures that have shaped ant nest architecture.This article is part of the theme issue ‘The evolutionary ecology of nests: a cross-taxon approach’.