The wide-ranging application of lithium-ion batteries (LIBs) is currently restricted by their slow ion dynamics and low capacity, which hinders the development of innovative electrode materials. Herein, the graphitic carbon nitride (g-C3N4)/TiVCTx composite was fabricated through in situ pyrolysis of urea to generate g-C3N4 nanosheets on the surface of TiVCTx nanosheets. The as-prepared g-C3N4 protective layer can reduce the degree of oxidation of TiVCTx MXene, restrain the re-stacking of TiVCTx nanosheets and minimize the risk of undesirable side reactions. As expected, the g-C3N4/TiVCTx electrode exhibits remarkable specific capacity of 1025.3 mAh/g after 150 cycles at 0.1 A/g and 558.3 mAh/g after 1000 cycles at 1.0 A/g for LIBs and a high specific capacitance of 508.9F g−1 in 0.5 M Na2SO4 electrolyte at 1.0 A/g after 7000 cycles for supercapacitors (SCs). Furthermore, the assembled g-C3N4/TiVCTx-30//LiFePO4 full cell presents stable specific capacity of 505.5 mAh/g at 0.1 A/g after 100 cycles and 255.2 mAh/g at 0.1 A/g along with a Coulombic efficiency of 97.9 % after 50 cycles at − 20 °C, demonstrating excellent low temperature tolerance. Density functional theory (DFT) calculation results indicated that the g-C3N4/TiVCTx-30 exhibits strongest adsorption capacity for Li+ with an adsorption energy of −3.85 eV. The introduction of g-C3N4 improves the insertion and extraction kinetics of Li+, effectively reducing the diffusion barrier. Consequently, the g-C3N4/TiVCTx-30 electrode exhibits potential application prospects in high-performance electrochemical energy storage devices. Our work provides valuable insights and significant research implications for improving the specific capacity and stability of TiVCTx MXene in the field of energy storage.