Alpha fetoprotein (AFP) is an embryonic glycoprotein that is produced by hepatocytes and soft yellow sacs, which is closely related to liver cell proliferation, as well as the development of cirrhosis, chronic hepatitis and other diseases. Thus, AFP has been widely used as an important tumor marker in the basic research and clinical diagnosis of diseases such as early-stage liver cancer, endodermal sinus tumors and germ cell tumors. In this study, we developed a near-infrared (NIR) fluorescent carbon quantum dots by microwave synthesis, and constructed a turn-on fluorescent nanosensor by unique modifications. This nanosensor not only has specific response to AFP, but also good biocompatibility and high photostability. The results show that the proposed NIR nanosensor has very high sensitivity, and its detection limit is 3.0 pg/mL for AFP. Thus, it was used for the accurate quantification of AFP in human serum and the imaging of AFP in vitro and in vivo. Therefore, the diagnosis of early-stage liver cancer can be achieved by using proposed method.