• The application of selenium treatment effectively curtailed the levels of NLRP3, IL-1β, TNF-α, ASC, and caspase-1 that resulted from S. aureus influence within the mammary gland of mice. Moreover, Se supplementation notably bolstered the antioxidant capacity, enhanced the anti-inflammatory response, and fortified the immune status of the mice population.• Beyond this, the administration of selenium emerged as a preventive strategy against mastitis, primarily attributed to its capability to inhibit NLRP3 inflammasome activation and suppress NF-κB/MAPK pathway signaling. The gene discussed is IL1B; the disease is mastitis.