Formaldehyde (HCHO) is the most common indoor hazardous pollutant and has attracted great concern because its long-term exposure has adverse health effects on humans. Retention and catalytic oxidation of highly hazardous HCHO is an efficient and environmentally friendly method to use for air remediation, but a major obstacle to this procedure is the lack of an appropriate catalyst. Herein, two-dimensional magnetic C4N3 material with a 3d-transition metal as activate sites was systemically investigated in HCHO oxidation using density functional theory calculations. The results show that V-C4N3 and Cr-C4N3 have high structural stability and shallow activation barriers for O2 decomposition; these characteristics provide the necessary precursors for the subsequent oxidation reaction. Moreover, the V-C4N3 and Cr-C4N3 catalysts have unique selective adsorption and catalysis toward HCHO in a mixture of some typical in-door volatile organic compounds (VOCs) and air. The corresponding dynamic barrier for each reaction step was investigated and the mechanism involved in HCHO oxidation was revealed in detail. Aggregation of metal atoms in the V-C4N3 and Cr-C4N3 catalysts is prevented by enormous diffusion resistance, and this is further confirmed by AIMD simulations. These results provide insightful guidance for developing advanced magnetic catalysts for HCHO oxidation to improve the remediation of air contaminants.