Termites are a lineage of social cockroaches abundant in tropical ecosystems where they are key decomposers of organic matter from wood to soil. Despite their ecological significance, only a handful of reference-quality termite genomes have been sequenced, which is insufficient to unravel the genetic mechanisms that have contributed to their ecological success. Here, we performed sequencing and hybrid assembly of 45 taxonomically and ecologically diverse termites and two cockroaches, resulting in haplotype-merged genome assemblies of 47 species, 22 of which were near-chromosome level. Next, we examined the link between termite dietary evolution and major genomic events. We found that Termitidae, which include ~80% of described termite species, have larger genomes with more genes and a higher proportion of transposons than other termites. Our analyses identified a gene number expansion early in the evolution of Termitidae, including an expansion of the repertoire of CAZymes, the genes involved in lignocellulose degradation. Notably, this expansion of genomes and gene repertoires coincided with the origin of soil-feeding in Termitidae and remained unchanged in lineages that secondarily reverted to a wood-based diet. Overall, our sequencing effort multiplied the number of available termite genomes by six and provided unprecedented insights into the genome evolution of the most ancient lineage of social insects.