The microbial community residing on the phyllosphere is influenced by many factors, including the host plant's genotype as well as its secondary metabolites. Anthocyanins are a group of flavonoids renowned for their antioxidative properties and are widely distributed across plant tissues. However, the potential impact of anthocyanins on plant-associated microbial communities remains unknown. In the model legume Medicago truncatula, we isolated a mutant named purple leaves (pl) that produces purple leaves at a young stage due to over-accumulated anthocyanins. Through sequencing 16S rRNA amplicons of phyllosphere microbes in the pl mutant, we show that anthocyanins significantly enhance the abundance of endophytic lactic acid bacteria within plant leaves. Further in vitro study revealed that anthocyanins derived from pl can significantly promote the growth of lactic acid bacteria under anaerobic conditions. The accumulated anthocyanins in pl leaves reduced reactive oxygen species (ROS), thereby creating a favorable environment for the growth of facultative anaerobic lactic acid bacteria and resultantly increasing the abundance of phyllosphere lactic acid bacteria. Our findings elucidate the role of anthocyanins in modulating the community structure of phyllosphere microbiota in M. truncatula and provide new insights into the relationship between plant secondary metabolites and phyllosphere microbiota.