BackgroundResearchers have investigated different techniques for synthesis of carbon dots. These techniques include Arc discharge, laser ablation, oxidation, water/solvothermal, and chemical vapor deposition. However, these techniques suffer from some limitations like the utilization of gaseous charged particles, high current, high temperature, potent oxidizing agents, non-environmentally friendly carbon sources, and the generation of uneven particle size. Therefore, there was a significant demand for the adoption of a new technology that combines the environmentally friendly aspects of both bio-based carbon sourcing and synthesis technique. ResultsMedicago sativa L (alfalfa)-derived N, S-CDs have been successfully synthesized via microwave irradiation. The N,S-CDs exhibit strong fluorescence (λex/em of 320/420 nm) with fluorescence quantum yield of 2.2 % and high-water solubility. The produced N,S-CDs were characterized using TEM, EDX, Zeta potential analysis, IR, UV–Visible, and fluorescence spectroscopy. The average diameter of the produced N, S-CDs was 4.01 ± 1.2 nm, and the Zeta potential was −24.5 ± 6.63 mv. The stability of the produced nano sensors was also confirmed over wide pH range, long time, and in presence of different ions. The synthesized N, S-CDs were employed to quantify the antibacterial drug, nifuroxazide (NFZ), by fluorescence quenching via inner filter effect mechanism. The method was linear with NFZ concentration ranging from 1.0 to 30.0 μM. LOD and LOQ were 0.16 and 0.49 μM, respectively. The method was applied to quantify NFZ in simulated gastric juice (SGJ) with % recovery 99.59 ± 1.4 in addition to pharmaceutical dosage forms with % recovery 98.75 ± 0.61 for Antinal Capsules® and 100.63 ± 1.54 for Antinal suspension®. The Method validation was performed in compliance with the criteria outlined by ICH. Significance and noveltyThe suggested approach primarily centers on the first-time use of alfalfa, an ecologically sustainable source of dopped-CDs, and a cost-effective synthesis technique via microwave irradiation, which is characterized by low energy consumption, minimized reaction time, and the ability to control the size of the produced CDs. This is in line with the growing global recognition of the implementation of green analytical chemistry principles.