Metal-ion hybrid capacitors represent an innovative class of electrochemical energy storage systems. However, hybrid capacitors made from traditional carbon-based materials struggle to simultaneously achieve both high specific capacity and long-cycle stability. A hierarchical porous carbon material with an optimized pore structure was synthesized using pig kidney proteins and tannic acid as precursors, employing cross-linking polymerization and carbonization activation strategies. The as-synthesized sample features an exceptionally high specific surface area and abundant porosity, which efficiently accommodate the adsorption and transport of solvated zinc and magnesium ions. The zinc-ion hybrid capacitor (ZHC) achieved a reversible capacity of 221 mA h g–1 at 0.2 A g–1, while the magnesium-ion hybrid capacitor (MHC) delivered 132 mA h g–1 under the same conditions. Additionally, DFT calculations revealed the critical influence of pore size on metal ion storage. In a 2 M ZnSO4 aqueous electrolyte solution, when the pore size of the carbon material was 1.13 nm, solvated zinc ions exhibited the highest adsorption energy. In contrast, in a 0.4 M (MgPhCl)2-AlCl3 organic electrolyte, a pore size of 2.29 nm optimized the storage capacity of solvated magnesium ions. This study provides important theoretical insights into designing ZHCs and MHCs.