This paper describes the synthesis of three-dimensionally porous Fe3O4 via template-assisted and subsequent electrochemical deposition methods. When used as anode materials of lithium–ion batteries, the porous Fe3O4 electrodes show better cyclability and enhanced rate capabilities compared to planar Fe3O4 electrodes. The superior performance can be attributed to improved electrical contact, fast electron transport and good strain accommodation of the porous electrodes. The effect of the thickness of the porous Fe3O4 electrodes on the lithium–ion battery performance has also been investigated.