Mastitis poses a huge economic burden, with antibiotics treatment leading to drug residues and the emergence of bacterial resistance. Therefore, there is an urgent need to develop alternatives to antibiotics for the treatment of mastitis. Anthocyanins (ACN) have excellent anti-inflammatory properties. However, the key pathways of mastitis disease progression and the therapeutic effects of ACN on mastitis remain poorly understood. In this study, using cows, goats, and mice as animal models, the efficacy of ACN extracts from crabapple fruit is investigated in alleviating the severity of mastitis and blood milk barrier (BMB) damage. A monomeric component, cyanidin 3-O-galactoside (C3Gal) is identified, that exhibited considerable effect on mastitis. Mechanistically, C3Gal regulated mastitis progression by inhibiting PANoptosis activation, and suppressing gasdermin D N-terminal activity to regulate BMB damage during mastitis. These findings establish PANoptosis as a critical pathway in the rapid progression of mastitis and highlight the potential of ACN extracts as effective alternatives to antibiotic for mastitis treatment. This study provides a promising strategy for the discovery and application of drugs for the treatment of inflammatory diseases, expands the application of ACN in inflammatory diseases, and elucidates the molecular mechanisms underlying its anti-inflammatory effect.