Transition metal oxides are widely researched as anode materials for lithium-ion batteries due to their high theoretical capacity. However, the application of this material is always restricted by the low electroconductivity and huge volume change. In this work, we develop a general strategy, the gelatin-assisted hydrothermal-calcination process, to prepare hierarchical porous transition metal oxides and their composites, including Fe2O3, Mn2O3, Co3O4, ZnCo2O4, MnCo2O4 and (Co,Mn)3O4. Depending on the unique molecular structure of gelatin, metal ions in the solution can be located in amino and carboxyl existing in natural polymer, which lead to the formation of hierarchical precursor. Typically, step-like hierarchical porous Fe2O3 and ZnCo2O4 exhibit the outstanding performance of 1301.7 mAh g−1 after 600 cycles and 1005.8 mAh g−1 after 180 cycles at 500 mA g−1 for lithium-ion storage. In addition, Na0.7MnO2 cathode material prepared from MnCO3 also delivers the 140.9 mAh g−1 over 50 cycles at 40 mA g−1 for sodium-ion storage. The stable structure, abundant materials, low toxicity and excellent performance promote the development of anode materials. Moreover, this easily-extended method also provides a strategy to obtain hierarchical materials, which expands the application of transition metal oxides in other fields.