Streptococcus pneumoniae (pneumococcus), a major human pathogen, is well known for its adaptation to various host environments. Multiple DNA inversions in the three DNA methyltransferase hsdS genes (hsdSA, hsdSB, and hsdSC) of the colony opacity determinant (cod) locus generate extensive epigenetic and phenotypic diversity. However, it is unclear whether all three hsdS genes are functional and how the inversions mechanistically occur. In this work, our transcriptional analysis revealed active expression of hsdSA but not hsdSB and hsdSC, indicating that hsdSB and hsdSC do not produce functional proteins and instead act as sources for altering the sequence of hsdSA by DNA inversions. Consistent with our previous finding that the hsdS inversions are mediated by three pairs of inverted repeats (IR1, IR2, and IR3), this study showed that the 15-bp IR1 and its upstream sequence are strictly required for the inversion between hsdSA and hsdSB Furthermore, a single tyrosine recombinase PsrA catalyzes the inversions mediated by IR1, IR2, and IR3, based on the dramatic loss of these inversions in the psrA mutant. Surprisingly, PsrA-independent inversions were also detected in the hsdS sequences flanked by the IR2 (298 bp) and IR3 (85 bp) long inverted repeats, which appear to occur spontaneously in the absence of site-specific or RecA-mediated recombination. Because the HsdS subunit is responsible for the sequence specificity of type I restriction modification DNA methyltransferase, these results have revealed that S. pneumoniae varies the methylation patterns of the genome DNA (epigenetic status) by employing multiple mechanisms of DNA inversion in the cod locus.IMPORTANCEStreptococcus pneumoniae is a major pathogen of human infections with the capacity for adaptation to host environments, but the molecular mechanisms behind this phenomenon remain unclear. Previous studies reveal that pneumococcus extends epigenetic and phenotypic diversity by DNA inversions in three methyltransferase hsdS genes of the cod locus. This work revealed that only the hsdS gene that is in the same orientation as hsdM is actively transcribed, but the other two are silent, serving as DNA sources for inversions. While most of the hsdS inversions are catalyzed by PsrA recombinase, the sequences bound by long inverted repeats also undergo inversions via an unknown mechanism. Our results revealed that S. pneumoniae switches the methylation patterns of the genome (epigenetics) by employing multiple mechanisms of DNA inversion.