Carbon dots (CDs) have attracted intense attention because of their excellent optical properties, low toxicity, and biocompatibility. CDs have a great potential to be used as fluorescent sensors and ultraviolet (UV)-blocking materials. In this research, CDs were synthesized by the hydrothermal method using mangosteen leaves as a precursor. A CD aqueous solution exhibited bright green (G-CDs) and red (R-CDs) fluorescence with naked-eye observation under UV irradiation. The maximum fluorescence emission peak intensities of G-CDs and R-CDs were observed at 312 nm and 671 nm under excitation wavelengths of 275 nm and 410 nm, respectively. The absorbance spectra of CDs are shown in the UV range of 200–400 nm. The transmission spectra indicate that the G-CD solution screens UVB and UVC, while R-CDs are an excellent block for all UVA, UVB, and UVC. The average UV-shielding efficiencies of R-CDs and G-CDs are 97.4 %, and 56.1%, respectively. Furthermore, the R-CDs have a tendency to screen high-energy blue light. FTIR results display functional groups of organic substance on CD surfaces showing that the CDs have good biocompatibility with organics and biological materials. Moreover, nanocomposite films of CDs and polyvinyl alcohol (PVA) polymer (CDs/PVA) were prepared using a drop-casting method. In the polymerized state, R-CDs/PVA and G-CDs/PVA exhibit significant improvements in average UV ray blockage of 100.0%, and 83.8% enhancement, respectively. It is noteworthy that PVA combined with R-CDs achieves complete UV ray blocking. Furthermore, the emissions from both CD solution and CDs/PVA under UV radiation cover the regions of red, green, and blue emission. Hence, this work demonstrates the performance of R-CDs- and G-CDs-based platforms that show a high potential for UV-shielding and sensing applications.