BackgroundCEUS LI-RADS (Contrast Enhanced Ultrasound Liver Imaging Reporting and Data System) has good diagnostic efficacy for differentiating hepatic carcinoma (HCC) from solid malignant tumors. However, it can be problematic in patients with both chronic hepatitis B and extrahepatic primary malignancy. We explored the diagnostic performance of LI-RADS criteria and CEUS-based machine learning (ML) models in such patients.MethodsConsecutive patients with hepatitis and HCC or liver metastasis (LM) who were included in a multicenter liver cancer database between July 2017 and January 2022 were enrolled in this study. LI-RADS and enhancement features were assessed in a training cohort, and ML models were constructed using gradient boosting, random forest, and generalized linear models. The diagnostic performance of the ML models was compared with LI-RADS in a validation cohort of patients with both chronic hepatitis and extrahepatic malignancy.ResultsThe mild washout time was adjusted to 54 s from 60 s, increasing accuracy from 76.8 to 79.4%. Through feature screening, washout type II, rim enhancement and unclear border were identified as the top three predictor variables. Using LI-RADS to differentiate HCC from LM, the sensitivity, specificity, and AUC were 68.2%, 88.6%, and 0.784, respectively. In comparison, the random forest and generalized linear model both showed significantly higher sensitivity and accuracy than LI-RADS (0.83 vs. 0.784; all P < 0.001).ConclusionsCompared with LI-RADS, the random forest and generalized linear model had higher accuracy for differentiating HCC from LM in patients with chronic hepatitis B and extrahepatic malignancy.Supplementary InformationThe online version contains supplementary material available at 10.1186/s40644-023-00573-8.