Bacillus cereus is a ubiquitous foodborne pathogen commonly found in various foods. Its ability to form spores, biofilms and diarrhoeal and/or emetic toxins further exacerbates the risk of food poisoning. Violacein is a tryptophan derivative with excellent antibacterial activity. However, the knowledge on the antibacterial action of violacein against B. cereus was lacking, and thus this study aimed to investigate the antibacterial activity and mechanism. The antibacterial results demonstrated that minimum inhibitory concentration and minimum bactericidal concentration of violacein were 3.125 mg/L and 12.50 mg/L, respectively. Violacein could effectively inhibit planktonic growth, spore germination and biofilm formation of B. cereus (P < 0.001). Meanwhile, violacein significantly downregulated the expression of toxin genes, including nheA (P < 0.05), nheB (P < 0.001), bceT (P < 0.01), cytK (P < 0.001), hblC (P < 0.001) and hblD (P < 0.001). Results of extracellular alkaline phosphatase, nucleotide and protein leakage assays and scanning and transmission electron microscopy observation tests showed violacein destroyed cell walls and membranes of B. cereus. In addition, 6.25 mg/kg of violacein could significantly inhibit B. cereus in grass carp fillets (P < 0.05). These results demonstrate that violacein has great potential as an effective natural antimicrobial preservative to control food contamination and poisoning events caused by B. cereus.