A fluorescent diagnostic probe for real-time intraoperative image-guided tumor resection can significantly improve the efficiency and quality of oncological therapy, but their development is challenging. Herein, a novel fluorescent diagnostic probe called HLTC based on β-carboline was designed and synthesized. HLTC was found to show a ∼10-fold enhancement of fluorescence quantum field with pH from 7.4 to 4.0, indicating its imaging potential in acid environment which is a typical hallmark of the tumor microenvironment (TME). Following fluorescence microscopy imaging showed HLTC could emit specific signals in cancer cells and sections, by both one-photon excitation and two-photon excitation. Importantly, HLTC enabled the precise and rapid delineation of both transplanted tumor and clinical tumor tissues within several minutes of simple topical spray. The tumor-to-background ratio (TBR) was up to 10.2 ± 1.0 at clinical liver cancer tissues and 9.9 ± 0.3 at clinical colon cancer tissues, allowing precise tumor margin identification and the effective guidance of surgical tumor resection. Furthermore, CCK8 assay, pharmacokinetic evaluation, blood analysis and H&E staining were performed, which verified high biocompatibility and biosafety of HLTC at working concentration. These results reveal the exciting potential of this small-molecule fluorescent diagnostic probe for real-time fluorescence-based navigation during surgical tumor resection.