The ubiquitous application of highly flammable acrylonitrile–butadienestyrene (ABS) resin has brought great fire threat to human and environment. Unfortunately, current flame retardants often improve flame retardancy but reduce mechanical and thermal properties, seriously affecting their practical application. We herein reported novel multifunctional, high-efficiency, phosphorus and nickel co-doped graphitic carbon nitride (Ni-P-C3N4) nanoflakes to address the trade-off between flame retardancy and mechanical/thermal properties. The addition of 2.0wt% of Ni-P-C3N4 increased the initial degradation temperature and tensile strength of ABS composite (ABS/Ni-P-CN2) by 15 °C and 24.3% relative to virgin ABS, indicating its positive effect on thermal and mechanical properties. Compared with ABS, ABS/Ni-P-CN2 exhibited a notable increase in time to ignition, along with 32.4% and 33.8% reductions in peak heat release rate (PHRR) and peak smoke production rate (PSPR), demonstrating excellent anti-ignition, flame-retardant and smoke-suppressive performances. The increased fire safety was mainly due to the physical barrier effect of g-C3N4 nanosheets and the catalytic charring effect of P and Ni. This work offers a novel design strategy to create multifunctional flame retardants for fabricating fire-safe polymer composites with superior thermal and mechanical properties, holding great potential in industries.