In the fields of public health, veterinary medicine, and aquaculture, niclosamide (NIC), a common anthelmintic drug, is essential for deworming and treating a variety of illnesses, such as viral infections, metabolic disorders, and cancer. However, NIC can pose potential risks, such as DNA damage and adverse vasodilation effects in vivo. This study introduces an innovative fluorescent nanosensor for the detection of NIC in food samples. The sensor utilises sulphur and nitrogen co-doped carbon dots (S,N-CDs) derived from eco-friendly materials, Turbo bruneus and L-cysteine, encapsulated within a molecularly imprinted polymer (S,N-CDs@MIP). The sensor operates on a “Turn Off” mechanism, where NIC binding results in decreased fluorescence intensity, effectively detecting NIC in the 1–10 µM concentration range. Excellent sensitivity is indicated by the calibration curve, which displays a strong linear connection between NIC concentration and fluorescence intensity (Y = 0.0612x + 0.0689, R2 = 0.9996) and a detection limit of 48.1 nM. The sensor is selective, user-friendly, and cost-effective, with NIC recoveries in food samples ranging from 96.33 to 103.23% and low RSD values (0.81 to 4.89%). Moreover, we utilized the AGREEMIP software to assess the greenness of MIP synthesis processes. This tool evaluates 12 criteria encompassing energy requirements, synthesis specifics, and the environmental impact of reaction components, providing a comprehensive measure of the produced MIP's sustainability. Compared to non-imprinted polymers, the S,N-CDs@MIP sensor offers superior optical stability and specificity, making it a promising tool for practical NIC detection in real-world applications.