N-rich metal-free and metal-doped carbon quantum dots (CQDs) have been prepared through one-step hydrothermal method using tetraphenylporphyrin or its transition metal (Pd or Pt) complex as precursor. The structures and morphology of the as-prepared nanoparticles were analyzed by X-ray diffraction, high-resolution transmission electron microscopy, X-ray photoelectron spectroscopy, and Fourier transform infrared spectra. Three kinds of nanocomposites show similar structures except for the presence of metal ions in Pd-CQDs and Pt-CQDs indicated by X-ray photoelectron spectroscopy. All of them display bright blue emission upon exposure to ultraviolet irradiation. The CQDs exhibit typical excitation-dependent emission behavior, with the emission quantum yield of 10.1%, 17.8%, and 15.2% for CQDs, Pd-CQDs, and Pt-CQDs, respectively. Moreover, the CQDs, Pd-CQDs, and Pt-CQDs could serve as fluorescent probes for the specific and sensitive detection of Fe
3+
ions in aqueous solution. The low cytotoxicity of CQDs is demonstrated by MTT assay against HeLa cells. Therefore, the CQDs can be used as efficient probes for cellular multicolor imaging and fluorescence sensors for the detection of Fe
3+
ions due to their low toxicity, excellent biocompatibility, and low detection limits. This work provides a new route to synthesize highly luminescent N-rich metal-free or metal-doped CQDs for multifunctional applications.