In this study potassium salts such as KF, KCl and KBr were doped onto g-C3N4 to form KX-g-C3N4 (X = F, Cl and Br) via a thermal method. The KX-g-C3N4 was characterized by various instrumentation techniques such as UV–visible, FT-IR, XRD, Photoluminescence, TGA, BET, Raman, SEM, EDAX, HR-TEM, and Zeta potential. KX-g-C3N4 was explored for the photocatalytic degradation of methylene blue (MB) under visible light irradiation. Among them, KF-g-C3N4 showed excellent photocatalytic degradation of methylene blue (MB) under visible light irradiation. The KF-g-C3N4 significantly reduced the electrons–holes recombination rate when compared to KCl-g-C3N4, KBr-g-C3N4 and g-C3N4. The photocatalytic degradation mechanism was also studied with KF-g-C3N4.