Nematode-trapping fungi (NTF), most of which belong to a monophyletic lineage in Ascomycota, cannibalize nematodes and other microscopic animals, raising questions regarding the types and mechanisms of genomic changes that enabled carnivorism and adaptation to the carbon-rich and nitrogen-poor environment created by the Permian-Triassic extinction event. To address these questions, we conducted comparative genomic analyses of 21 NTF and 21 non-NTF. Carnivorism-associated changes include expanded genes for nematode capture, infection, and consumption (e.g., adhesive proteins, CAP superfamily, eukaryotic aspartyl proteases, and serine-type peptidases). Although the link between secondary metabolite (SM) production and carnivorism remains unclear, we found that the number of SM gene clusters in NTF was significantly lower than that in non-NTF. Significantly expanded cellulose degradation gene families (GH5, GH7, AA9, and CBM1) and contracted genes for carbon-nitrogen hydrolases (enzymes that degrade organic nitrogen to ammonia) are likely associated with adaptation to carbon-rich and nitrogen-poor environments. Through horizontal gene transfer events from bacteria, NTF acquired the Mur gene cluster (participating in synthesizing peptidoglycan of the bacterial cell wall) and Hyl (a virulence factor in animals). Disruption of MurE reduced NTF's ability to attract nematodes, supporting its role in carnivorism. This study provides new insights into how NTF evolved and diversified, presumably after the Permian-Triassic mass extinction event.