A one step strategy was employed for the preparation of phosphorous doped g‐C3N4 (P‐g‐C3N4) using melamine phosphate. Herein, the precursor upon thermal condensation at 550º C resulted in the formation of P‐g‐C3N4 nanosheets. The as‐synthesised P‐g‐C3N4 nanosheets were characterized by UV‐vis, FT‐IR and Raman spectroscopy. Later, surface morphological analysis were carried out using FESEM and HRTEM. Moreover, the crystalline nature and elemental composition analysis were conducted using XRD and XPS. Following this, P‐g‐C3N4 nanosheets modified glassy carbon (GC) electrode was employed for the simultaneous detection of xanthene and caffeine. The modified electrode was found to be linear in the range of 0.1 to 100 μM (for xanthine) and 0.05 to 100 μM (for caffeine). The limit of detection was found to be 10 nM and 14 nM for xanthine and caffeine respectively. Further, the electrode exhibited a highly selective detection towards each of these analyte when they co‐exists.