The synthesis of two-dimensional (2D) graphitic g-C3N4 and heteroatom-doped graphitic H@g-C3N4 (H: B, P, or S) particles were successfully done using melamine as source compounds and boric acid, phosphorous red, and sulfur as doping agents. The band gap values of 2D g-C3N4, B50@g-C3N4, P50@g-C3N4, and S50@g-C3N4 structures were determined as 2.90, 3.03, 2.89, and 2.93 eV, respectively. The fluorescent emission wavelengths of 2D g-C3N4, B50@g-C3N4, P50@g-C3N4, and S50@g-C3N4 structures were observed at 442, 430, 441, and 442 nm, respectively upon excitation at λ Ex = 325 nm. There is also one additional new emission wavelength was found at 345 nm for B50@g-C3N4 structure. The blood compatibility test results of g-C3N4, B50@g-C3N4, P50@g-C3N4, and S50@g-C3N4 structures revealed that all materials are blood compatible with <2% hemolysis and >90% blood clotting indices at 100 μg ml−1 concentration. The cell toxicity of the prepared 2D graphitic structures were also tested on L929 fibroblast cells, and even the heteroatom doped has g-C3N4 structures induce no cytotoxicity was observed with >91% cell viability even at 250 μg ml−1 particle concentration with the exception of P50@g-C3N4 which as >75 viability. Moreover, for 2D g-C3N4, B50@g-C3N4, and S50@g-C3N4 constructs, even at 500 μg ml−1 concentration, >90% cell viabilities was monitored. As a diagnostic material, B50@g-C3N4 was found to have significantly high penetration and distribution abilities into L929 fibroblast cells granting a great potential in fluorescence imaging and bioimaging applications. Furthermore, the elemental doping with B, P, and S of g-C3N4 were found to significantly increase the photodynamic antibacterial activity e.g. more than half of bacterial elimination by heteroatom-doped forms of g-C3N4 under UVA treatment was achieved.