Valacyclovir (VAL), as a prodrug to acyclovir antiviral agent, has recently held a lot of interest for its efficacy boosting owing to the significant improvement in bioavailability. This makes it a successful candidate in the management of herpes simplex strains as well as CORONA viruses. In this work a carbon nano dot-modified glassy carbon electrode (GCE) has been optimized as potentiometric sensor for the assay of VAL through a systematic approach. A mixture components of polyvinyl chloride (PVC) membrane have been selected and fine-tuned for optimum sensitivity and selectivity. The best results have been obtained by drop casting a blend in % w/w of PVC; 30.85, tricrasyl phosphate (TCP) as plasticizer; 64.32, phosphotungstic acid (PT) as cation exchanger; 1.61 and phosphorus – nitrogen-doped carbon nano-dots (PNCDs); 3.22 over the GCE. The density function theory (DFT) calculations have been applied to the optimized structures of VAL and the CDs and have proven high binding affinity of 46 kcal/mol dominated by π-π stacking and hydrogen bonding. The developed sensor has exhibited a swift response time of six seconds at a 5.00 pH value. The ICH guidelines have been applied to validate the optimized parameters. A good linearity range has been obtained from 1.18 × 10-3 down to 1.07 × 10-6 M for a correlation coefficient 0.9996 with a Nernstian slope of 33.16 mV/decade. The greenness has been assessed using the AGREE approach, giving a score of 0.8, which has indicated the environmental friendliness. An average % recovery of almost 99.00 % was obtained by application to the tablet formulations and furtherly it has been monitored by the standard addition method, giving recoveries varied from 98.00 and up to 102.00 % for relative standard deviation values (%RSD) less than 1.50 %, evidencing efficiency for application in the quality control laboratories.