• In the context of S. aureus exposure, there was an observable increase in the expression of NLRP3, ASC, caspase-1, caspase-1 p20, and pro-IL-1β, thus intensifying the inflammatory response.• Conversely, the supplementation of selenium exerted a substantial inhibitory effect on the levels of NLRP3, ASC, caspase-1, caspase-1 p20, and pro-IL-1β.• This outcome stands as compelling evidence that selenium treatment serves as a preventive measure against S. aureus-induced mastitis in mice, achieved by effectively curtailing the NLRP3 level. The gene discussed is NLRP3; the disease is mastitis.