As the primary organ for drug metabolism and detoxification, the liver is susceptible to damage and seriously impaired function. In situ diagnosing and real-time monitoring of liver damage are thus of great significance but remain limited owing to the lack of reliable in vivo visualization protocols with minimal invasion. Herein, we reported for the first time an aggregation-induced emission (AIE) probe, namely DPXBI, emitting light in the second near-infrared window (NIR-II) for early diagnosis liver injury. DPXBI featured by strong intramolecular rotations, excellent aqueous solubility and robust chemical stability, is powerfully sensitive to viscosity alteration affording rapid response and high selectivity, through NIR-Ⅱ fluorescence intensity changes. The prominent viscosity-responsive performance enables DPXBI to accurately monitor both drug-induced liver injury (DILI) and hepatic ischemia-reperfusion injury (HIRI) with excellent image contrast to the background. By using the presented strategy, the detection of liver injury in mouse model can be achieved at least several hours earlier than typical clinical assays. Moreover, DPXBI is able to dynamically track the liver improvement process in vivo in the case of DILI when the hepatotoxicity is alleviated by using hepatoprotective medication. All these results demonstrate that DPXBI is a promising probe for investigating viscosity-associated pathological and physiological processes.