Abstract Invertible promoters (invertons) are regulatory elements found in bacteria, with inverted repeat sequences at both ends, leading to alternating changes in the expression of the regulated genes. Since invertons were present in more than 20% of bacterial genomes, while they regulated more than 5% of genes in these genomes, they are of pivotal importance for microbial functional dynamics especially when under stress. However, the prevalence of invertons, as well as the full spectrum of gene functions regulated by them, remain poorly understood. In this study, we developed DeepInverton, a deep learning model capable of accurately identifying novel inverton sequences without sequencing reads, which could profile inverton sequences from large genomic and metagenomic datasets. We conducted a pan-genomic and pan-metagenomic analysis of invertons on 68,969 bacterial genomes and 8,516 metagenome samples, resulting in a comprehensive overview of more than 200,000 nonredundant invertons and their regulated gene functional patterns. This result suggests that invertons, as a key player for bacterial adaptation to environmental stresses, are prevalent in bacterial genomes. Among the genomes analyzed, we observed a profound enrichment of invertons in pathogen such as Bordetella pertussis , and discovered a significant increase of inverton enrichment rates in strains associated with recent pertussis outbreaks, as well as novel evolving strains, unveiling a hidden link between the evolution of Bordetella pertussis and its inverton enrichment. We also utilized DeepInverton to explore inverton profiles mong human and marine metagenomes. Results revealed an unprecedented diversity of functional genes regulated by invertons, including antimicrobial resistance, biofilm formation and flagella, indicating their potential role in facilitating environmental adaptation. The in vitro experiments have confirmed the functions of tens of novel invertons that we have identified. Overall, we developed the DeepInverton model for exploration of invertons at unprecedented scale, which enabled our comprehensive profiling of invertons and their regulated genes. The comprehensive inverton profiles have deepen our understanding of invertons at pan-genome and metagenome scale, and could enabled a broad spectrum of inverton-related applications in microbial ecology and synthetic biology.