Introduction: Hepatocellular carcinoma (HCC) is one of the most common malignant tumors in the world. The overall prognosis of patients with HCC is not very ideal. Early detection of HCC has become one of the important means to reduce mortality. More and more studies have pointed out that inflammatory markers based on hematology, such as Onodera’s prognostic nutritional index (OPNI), have important clinical significance. However, there is a lack of relevant research on the diagnosis of HCC by inflammatory markers. Methods: We retrospectively enrolled 633 patients and prospectively recruited 121 consecutive patients, to explore the correlation between inflammatory markers and diagnosis of HCC. Based on the prognostic indicators, different diagnostic models were constructed and the diagnostic performance of different models was further compared. Results: The best cutoff value of OPNI in the diagnosis of HCC is 43.925. Area under the receiver operating characteristics curve (AUC) of gender + age + AFP + OPNI diagnosis of HCC is 0.837 (95% CI: 0.702–0.868) in the retrospective cohort. Compared with gender + age + AFP, the Nagelkerke R<sup>2</sup> of gender + age + AFP + OPNI increased from 0.234 to 0.426, and AUC increased by 0.0973 (95% CI: 0.0659–0.1290). DeLong test, net reclassification improvement (NRI) test, and integrated discrimination improvement (IDI) test are all statistically significant. In the prospective cohort, AUC of gender + age + AFP + OPNI diagnosis of HCC is 0.782 (95% CI: 0.696–0.869). Compared with gender + age + AFP, NRI test is statistically significant (categorical 0.0909 [95% CI: 0.0060–0.1759], p = 0.0359). Conclusion: In the process of monitoring the occurrence of HCC in patients with risk factors, OPNI can be included as appropriate to improve the accuracy of HCC diagnosis.