This study aimed to explore the predictive value of liver and spleen stiffness measurement based on two-dimensional shear wave elastography for the portal vein pressure in patients with compensatory viral cirrhosis. From January 2017 to August 2019, 107 patients with compensatory viral cirrhosis and 76 patients with viral hepatitis were enrolled as cirrhosis group and hepatitis group, respectively. Patient data were obtained during admission, and this study was a review and analysis of patient data. Liver stiffness measurement (LSM), spleen stiffness measurement (SSM), portal vein diameter and spleen thickness were compared between the two groups, and their diagnostic value for compensatory viral cirrhosis was analyzed. According to the hepatic vein pressure, the cirrhosis group patients were divided into non-hypertensive group (no portal hypertension, hepatic venous pressure gradient (HVPG) < 5 mmHg), mild group (mild portal hypertension, 5 mmHg ≤ HVPG ≤ 10 mmHg) and severe group (clinically significant portal hypertension group, HVPG > 10 mmHg). LSM, SSM, portal vein diameter and spleen thickness of the three groups were compared, and the correlation between SSM and hepatic vein pressure was analyzed. LSM, SSM, portal vein diameter and spleen thickness in the cirrhosis group were higher than those in hepatitis group (all P<0.05). The area under the curve (AUC) of combined detection was larger than that of LSM, SSM and spleen thickness detection alone in liver cirrhosis diagnosis (all P<0.05). LSM, SSM, portal vein diameter and spleen thickness increased with the increase of hepatic vein pressure in patients with liver cirrhosis (all P<0.05). LSM, SSM, portal vein diameter and spleen thickness were all positively correlated with hepatic vein pressure (P<0.05). ROC curve showed that AUC of combined detection was greater than that of LSM, SSM, portal vein diameter and spleen thickness alone detection in the diagnosis of clinically significant portal hypertension (all P<0.05). The increase of LSM, SSM, portal vein diameter and spleen thickness were the influencing factors for hepatic vein pressure rising (all P<0.05). There was an increase of LSM and SSM in patients with compensatory viral cirrhosis, which were positively correlated with hepatic venous pressure, and combined index detection has diagnostic and predictive value for the change of portal venous pressure.