Nepetoidin B (NB) has been reported to possess anti-inflammatory, antibacterial, and antioxidant properties. However, its effects on liver ischemia/reperfusion (I/R) injury remain unclear. In this study, a mouse liver I/R injury model and a mouse AML12 cell hypoxia reoxygenation (H/R) injury model were used to investigate the potential role of NB. Serum transaminase levels, liver necrotic area, cell viability, oxidative stress, inflammatory response, and apoptosis were evaluated to assess the effects of NB on liver I/R and cell H/R injury. Quantitative polymerase chain reaction (qPCR) and Western blotting were used to measure mRNA and protein expression levels, respectively. Molecular docking was used to predict the binding capacity of NB and mitogen-activated protein kinase phosphatase 5 (MKP5). The results showed that NB significantly reduced serum alanine aminotransferase (ALT) and aspartate aminotransferase (AST) levels, liver necrosis, oxidative stress, reactive oxygen species (ROS) content, inflammatory cytokine content and expression, inflammatory cell infiltration, and apoptosis after liver I/R and AML12 cells H/R injury. Additionally, NB inhibited the JUN protein amino-terminal kinase (JNK)/P38 pathway. Molecular docking results showed good binding between NB and MKP5 proteins, and Western blotting results showed that NB increased the protein expression of MKP5. MKP5 knockout (KO) significantly diminished the protective effects of NB against liver injury and its inhibitory effects on the JNK/P38 pathway. NB exerts hepatoprotective effects against liver I/R injury by regulating the MKP5-mediated P38/JNK signaling pathway.