Formaldehyde is a typical indoor air pollutant that has posed severely adverse effects on human health. Herein, a novel FeCo alloy nanoparticle-embedded nitrogen-doped carbon (FeCo@NC) was synthesized with the aim of tailoring the transition-metal d-band structure toward an improved formaldehyde oxidation activity for the first time. A unique core@shell metal–organic frameworks (MOFs) architecture with a Fe-based Prussian blue analogue core and Co-containing zeolite imidazole framework shell was firstly fabricated. Then, Fe and Co ion alloying was readily achieved owing to the inherent MOF porosity and interionic nonequilibrium diffusion occurring during pyrolysis. High-angle annular dark-field scanning transmission electron microscopy and X-ray absorption fine structure spectra confirm that small FeCo alloys in situ form in FeCo@NC, which exhibits a higher formaldehyde removal efficiency (93%) than the monometallic Fe-based catalyst and a remarkable CO2 selectivity (85%) at room temperature. Density functional theory calculations indicate the number of electrons transferred from the metal core to the outer carbon layer is altered by alloying Fe and Co. More importantly, a downshift in the d-band center relative to the Fermi level occurs from − 0.93 to − 1.04 eV after introducing Co, which could alleviate the adsorption of reaction intermediates and greatly improve the catalytic performance.