African swine fever (ASF), caused by ASF virus (ASFV) infection, poses a huge threat to the pork industry owing to ineffective preventive and control measures. Hence, there is an urgent need to develop strategies, including antiviral drugs targeting ASFV, for preventing ASFV spread. This study aimed to identify novel compounds with anti-ASFV activity. To this end, we screened a small chemical library of 102 compounds, among which the natural flavonoid dihydromyricetin (DHM) exhibited the most potent anti-ASFV activity. DHM treatment inhibited ASFV replication in a dose- and time-dependent manner. Furthermore, it inhibited porcine reproductive and respiratory syndrome virus and swine influenza virus replication, which suggested that DHM exerts broad-spectrum antiviral effects. Mechanistically, DHM treatment inhibited ASFV replication in various ways in the time-to-addition assay, including pre-, co-, and post-treatment. Moreover, DHM treatment reduced the levels of ASFV-induced inflammatory mediators by regulating the TLR4/MyD88/MAPK/NF-κB signaling pathway. Meanwhile, DHM treatment reduced the ASFV-induced accumulation of reactive oxygen species, further minimizing pyroptosis by inhibiting the ASFV-induced NLRP3 inflammasome activation. Interestingly, the effects of DHM on ASFV were partly reversed by treatment with polyphyllin VI (a pyroptosis agonist) and RS 09 TFA (a TLR4 agonist), suggesting that DHM inhibits pyroptosis by regulating TLR4 signaling. Furthermore, targeting TLR4 with resatorvid (a specific inhibitor of TLR4) and small interfering RNA against TLR4 impaired ASFV replication. Taken together, these results reveal the anti-ASFV activity of DHM and the underlying mechanism of action, providing a potential compound for developing antiviral drugs targeting ASFV.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13567-023-01184-8.