The invention relates to bacillus velezensis and an application thereof in prevention and treatment of porcine diarrhea. The invention provides a bacillus velezensis strain LL2018013. The bacillus velezensis is added into a weaned piglet milk replacer, wherein the addition amount is 107 to 109 CFU/L; and the bacillus velezensis is added into a feed for pigs at growth periods, wherein the additionamount is 106 to 108 CFU/g. The bacillus velezensis provided by the invention can improve the diversity of pig intestinal flora, reduces inflammatory factors through regulation of the flora abundance,promotes nutrient digestion and absorption, improves oxidation resistance of a body, improves immunity, increases the resisting capability to viruses, reduces generation of diarrhea, can inhibit common pig intestinal pathogens like escherichia coli K88, salmonella typhimurium and staphylococcus aureus, reduces the rate of diarrhea, improves the daily gain of pigs, can inhibit molds in a feed, improves the metabolic efficiency of the body to lipids, improves digestion and absorption of the pigs to feed nutritional ingredients, and has the trend of reducing chemical residues in excrement at thesame time.