: In order to explore the optimal extraction conditions of allicin and its effects on Escherichia coli and Staphylococcus aureus. In this experiment, purple peel garlic is used as the material. The effects of solid-liquid ratio, ethanol concentration, extraction temperature and extraction time on the extraction of allicin are studied by organic solvent method combined with orthogonal test. The bacteriostatic effect of allicin on Escherichia coli and Staphylococcus aureus is determined by filter paper method. The results show that when the solid-liquid ratio is 1:5, the ethanol concentration is 85%, the extraction temperature is 40 ℃ and the extraction time is 1.5 h, the maximum extraction yield of allicin is 0.43%. Allicin has obvious inhibitory effect on Escherichia coli and Staphylococcus aureus. The minimum inhibitory concentration of allicin is 62.5, 31.25 mg/mL respectively, and the inhibition of Staphylococcus aureus is stronger than that of Escherichia coli. The experimental results have provided a theoretical basis for the future study on allicin.