BackgroundCantharidin (CTD) is a major ingredient of cantharis (Mylabris phalerataPallas) and has been used extensively in traditional Chinese medicines. It has been shown to exhibit anticancer activity in multiple types of cancer, especially hepatocellular carcinoma (HCC). However, there is no systematic study on the relationships among the regulatory networks of its targets in HCC therapy. We focused on histone epigenetic regulation and the influence of CTD on the immune response in HCC.MethodsWe performed a comprehensive analysis of novel CTD targets in HCC based on network pharmacology and RNA-seq approaches. The mRNA levels of target genes were analyzed by qRT-PCR, and the corresponding protein levels were confirmed using enzyme-linked immunosorbent assay (ELISA) and immunohistochemical staining (IHC). ChIP-seq data were visualized by IGV software. The associations of gene transcript levels with the cancer immune score and infiltration level were investigated using TIMER. In vivo, the H22 mouse model of hepatocellular carcinoma was established by treatment with CTD and 5-Fu. The immune cell proportions in the blood were elevated in model mice, as shown by flow cytometry.ResultsWe identified 58 targets of CTD, which were involved in various pathways in cancer, including apoptosis, the cell cycle, EMT and immune pathways. Moreover, we found that 100 EMT-related genes were differentially expressed after CTD treatment in HCC cells. Interestingly, our results confirmed that the EZH2/H3K27me3 -related cell cycle pathway is a therapeutic target of CTD in antitumour. In addition, we evaluated the influence of CTD on the immune response. Our data showed that the significantly enriched gene sets were positively correlated with the chemokine biosynthetic and chemokine metabolic modules. The proportions of CD4+/CD8 + T cells and B cells were increased, but the proportion of Tregs was decreased after treatment with CTD in vivo. Moreover, we found that the expression of the inflammatory factor and immune checkpoint genes PD­1/PD-L1 was significantly reduced in the mouse model.ConclusionWe performed a novel integrated analysis of the potential role of CTD in HCC treatment. Our results provide innovative insight into the mechanism by which cantharidin exerts antitumour effects by regulating target genes expression to mediate apoptosis, EMT, cell cycle progression and the immune response in HCC. Based on the effect of CTD on the immune response, it can be used as a potential effective drug to activate antitumour immunity for the treatment of liver cancer.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12906-023-03975-0.