A fluorescent sensor based on nitrogen-doped graphene quantum dots (N-GQDs) was developed for the smartphone-assisted colorimetric determination of diflunisal. The fluorescence source was embedded with zinc oxide (ZnO) in a molecularly imprinted polymer (ZnO@N-GQDs@MIP). The quantitative analysis was based on the fluorescence quenching caused by electron transfer from the nanoprobe to diflunisal. The sensor demonstrated linearity in the range of 0.10–50.0 μg L−1 with a limit of detection of 0.03 μg L−1. Smartphone-assisted on-site determination produced linearity in the range of 1.0–50.0 µg/L with a limit of detection of 0.30 μg L−1. The developed sensor was applied to determine diflunisal in milk, egg and yogurt samples. Recoveries ranging from 94.8 to 103.7 % were achieved with a RSD below 2.0 % measured by fluorescence spectroscopy, and from 94.9 to 106.9 % with a RSD of <6 % smatphone-assisted measurement. Comparison of the detection outcomes of both methods with those of high-performance liquid chromatography revealed consistent results, demonstrating the accuracy of the developed method, which was also sensitive, selective, and fast. Notably, the portable and easy-to-read smartphone-assisted method is suitable for on-site application.