The invention provides a fresh-keeping agent for bacillus subtilis and a preparation method thereof, wherein the preparation method comprises the following steps: S1, preparing a culture medium, and inoculating a solid culture medium with a prepared bacillus subtilis strain; S2, extracting bacillus subtilis on the solid culture medium after overnight, and inoculating into a liquid culture medium;S3, keeping the liquid culture medium inoculated with bacillus subtilis in a state of oscillation; S4, after overnight, filtering the liquid culture medium and bacillus subtilis in the liquid culturemedium, removing the bacteria through a bacterial filter, and collecting a filtrate; S5, extracting a precipitated protein in the filtrate by a fractional precipitation method; and S6, furthermore collecting a precipitate under a centrifugal condition, dissolving in a buffer solution, carrying out dialysis treatment on the buffer solution, and desalting to obtain an antibacterial protein. The fresh-keeping agent for bacillus subtilis can realize bacteriostasis of fruit and vegetable pathogenic bacteria, thereby realizing fresh keeping of fruits and vegetables, prolonging the storage period ofthe fruits and vegetables, and facilitating the transportation and storage of the fruits and vegetables.