BabaoDan (BBD) is a famous traditional Chinese formula frequently used in TCM clinics to eliminate jaundice and treat infectious viral hepatitis. This paper assesses BBD's preventive and therapeutic effects on hepatic encephalopathy after liver cirrhosis (CHE) and acute liver failure (AHE) in rats and explains its possible mechanism of action. CHE rat model was established by injection of carbon tetrachloride (CCl4) twice a week for a total of 9 weeks and then by injection of thioacetamide (TAA) to induce hepatic encephalopathy. AHE rat model was established by injection of TAA once a day for a total of 3 days. In CHE rat model, BBD was gavaged once a day at the end of the 6th week until the experiment ended. In AHE rat model,BBD was gavaged once a day 3 days before TAA injection until the experiment ended. The preventive and therapeutic effects of BBD on brain dysfunction, as well as liver injury, pathology and fibrosis were evaluated in vivo. The role of BBD in the regulation of inflammatory factors and myeloid differentiation factor 88/Toll-like receptor 4/nuclear factor kappa-B (TLR4/MyD88/NK-κ B) pathway was detected in both liver and brain in vivo. The rat bone marrow derived macrophages (BMDMs) were activated by Lipopolysaccharide (LPS), and the role of BBD in the regulation of inflammatory factors and NK-κ B pathway were detected in vitro. In CHE rat model: BBD significantly improved the total distance as well as the activity rate of rats. BBD also improved the learning and memory abilities of rats compared with the control group. In addition, BBD effectively decreased ammonia levels and significantly decreased the levels of alanine aminotransferase (ALT), aspartate transaminase (AST), total bilirubin (TBil) and total bile acid (TBA), as well as improved the levels of total protein (TP) and albumin (Alb). In the liver, BBD not only inhibited the gene expressions of tumor necrosis factor alpha (TNF-α), interleukini-6 (IL-6), TLR4, MyD88, and NF-κ B but also inhibited the protein expressions of TLR4, MyD88, NK-κ B and TNF-α. In the brain, BBD inhibited the gene expressions of iNOS, IL-6, TNF-α, TLR-4, MyD88, and NF-κ B, as well as inhibited the protein expressions of TLR4, MyD88, P65 TNF-α and ionized calcium binding adapter molecule 1 (Iba-1). BBD also decreased NO and TNF-α in the blood. BBD improved neurological scores, blood ammonia levels and the brain inflammatory gene expressions of iNOS, TNF-α and IL-1β. BBD also improved liver function biomarkers such as ALT, TBil, TBA, TP, ALB and inflammatory and apoptotic gene expressions of TNF-α, IL-1β, IL-6, Bax, Bcl-2, caspase-9, caspase-3 and NF-κ B. In LPS-activated rat BMDMs, BBD decreased NO and TNF-α production in BMDM culture supernatant. In addition, BBD inhibited the gene expressions of TNF-α, IL-1 β and IL-6 as well as the phosphorylation of P65. BBD can prevent and cure hepatic encephalopathy (HE) derived from both chronic and acute liver diseases. BBD can reduce hyperammonemia as well as the systematic and neurological inflammation. Inflammation is likely an important target of BBD to treat HE. The anti-inflammatory role of BBD may lie in its regulation of the TLR4/MyD88/NF-κ B pathways.