This paper is devoted to synthesizing a new type of CDs (carbon dots) with excellent NIR (near-infrared) emission in a biological water environment synthesized from small molecules. Citric acid was adopted as the precursor and treated by one-pot hydrothermal process in DMF solution with the assistance of a microwave. Urea (MH) and ammonium fluoride (MF) were adopted as nitrogen sources to synthesize two types of CDs, respectively. These conditions contributed to generate nanostructured carbon with a higher content of Pyrrolic-N, enrich the functional groups, and exfoliate the ordered layer-stacking structure, which finally contributed to the higher NIR absorption band at 808 nm. The physicochemical properties and photothermal conversion ability were fully evaluated by UV–Vis-NIR (ultraviolet–visible light-NIR) absorption and photothermal experiments. MF possessed stronger absorption property and temperature-rising effect in the NIR region than MH, but both exhibited desirable photothermal stability. Next, the in vitro and in vivo experiments demonstrated that both MF and MH exhibited no significant toxicity for cells. NIR irradiation on CDs solution displayed an excellent killing effect on HeLa (breast cancer) and MCF7 (cervical cancer) cells but strongly depended on the concentration of CDs. MH had a weaker killing effect on MCF7 cells compared with MF in the same concentration. But HeLa cells suffered death from lower concentration of MH under NIR irradiation. Both MH and MF exhibited excellent therapy effects and no obvious tissue damage for these major organs of nude mice and BALB/C mice. Above all, both MF and MH with excellent photothermal effect under NIR irradiation had desirable NIR-triggered therapeutic effect on MCF7 and HeLa cells, while they also exhibited good biocompatibility without NIR irradiation.