A facial and efficient process for the synthesis of porous ZnxCo3-xO4 hollow nanoboxes using zeolitic imidazolate frameworks as precursors has been demonstrated in this study, the as-prepared electrodes are applied for both LIBs and SIBs. The porous structure and hollow interspace can not only provide valuable channels and voids for lithium/sodium ion transfer and storage, but also buffer the stress/strain caused by volume changes. Besides, the enhanced electrical conductivity can effectively improve the reaction kinetics by synergistic effect of the binary metal oxides, as studied by density functional theory (DFT) calculations and storage mechanism studies. For lithium-ion batteries, the electrode exhibits an ultrahigh reversible capacity of 1141.7 mAh g−1, with an initial coulombic efficiency of 95.6%, and an ultralong life up to 800 cycles at 500 mA g−1. Even at a high current of 3.0 A g−1, a superior capacity of 484 mAh g−1 can be achieved. When using for sodium-ion battery anode, the reversible capacity is remained at 310 mAh g−1 after 100 cycles at 200 mA g−1, with a capacity retention of 90.4%. The electrode materials show long-term cycle stability and excellent rate capability, which gives a bright prospect for energy storage devices.