Abstract 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. Here, we conducted comparative genomic analyses of 21 NTF and 21 non-NTF to address these questions. 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 numbers of SM gene clusters among NTF are significantly lower than those among 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 the carbon-rich and nitrogen-poor environment. 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 after the Permian-Triassic mass extinction event.