The relationship between animals and their gut flora is simultaneously one of the most common and most complex symbioses on Earth. Despite its ubiquity, our understanding of this invisible but often critical relationship is still in its infancy. We employed adult Neotropical butterflies as a study system to ask three questions: First, how does gut microbial community composition vary across host individuals, species and dietary guilds? Second, how do gut microbiota compare to food microbial communities? Finally, are gut flora functionally adapted to the chemical makeup of host foods? To answer these questions we captured nearly 300 Costa Rican butterflies representing over 50 species, six families, and two feeding guilds: frugivores and nectivores. We characterized bacteria and fungi in guts, wild fruits, and wild nectars via amplicon sequencing and assessed the catabolic abilities of the gut microbiota via culture‐based assays. Gut communities were distinct from food communities, suggesting that the gut environment acts as a filter on potential colonists. Nevertheless, gut flora varied widely among individuals and species. On average, a pair of butterflies shared 21% of their bacterial species and 6% of their fungi. Host species explained 25–30% of variation in microbial communities while host diet explained 4%, suggesting that non‐dietary aspects of host biology play a large role in structuring the butterfly gut flora. Much of the variation between species correlated with host phylogeny. Host diet was related to gut microbial function: compared to frugivores, nectivores’ gut flora exhibited increased catabolism of sugars and sugar alcohols and decreased catabolism of amino acids, carboxylic acids, and dicarboxylic acids. Since fermented juice contains more amino acids and less sugar than nectar, it appears that host diet filters the gut flora by favoring microbes that digest compounds abundant in foods. By quantifying the degree to which gut communities vary among host individuals, species and dietary guilds and evaluating how gut microbial composition and catabolic potential are related to host diet, this study highlights the linkages between structure and function in one of the most complex and ubiquitous symbioses in the animal kingdom.