Peanuts are susceptible to aflatoxins produced by Aspergillus flavus. Exploring green, efficient, and economical ways to inhibit Aspergillus flavus is conducive to controlling aflatoxin contamination from the source. In this study, Ag-loaded titanium dioxide composites showed more than 90% inhibition rate against Aspergillus flavus under visible light irradiation for 15 min. More importantly, this method could also reduce the contaminated level of Aspergillus flavus to prevent aflatoxins production in peanuts, and the concentrations of aflatoxin B1, B2, and G2 were decreased by 96.02 ± 0.19%, 92.50 ± 0.45%, and 89.81 ± 0.52%, respectively. It was found that there are no obvious effects on peanut quality by evaluating the changes in acid value, peroxide value, and the content of fat, protein, polyphenols, and resveratrol after inhibition treatment. The inhibition mechanism was that these reactive species (•O2−, •OH−, h+, and e−) generated from photoreaction destroyed cell structures, then led to the reduced viability of Aspergillus flavus spores. This study provides useful information for constructing a green and efficient inhibition method for Aspergillus flavus on peanuts to control aflatoxin contamination, which is potentially applied in the field of food and agri-food preservation.