The energy harvesting performance and resulting flow structures of a hydrofoil oscillating in pitch and heave are studied experimentally in a water flume. The shape of a hydrofoil cross-section is shown to have negligible influence on the power generation for the geometries tested. It is found that contribution to efficiency from heaving motion increases with reduced frequency at optimal pitching amplitude. However, contribution to efficiency from pitching motion decreases with reduced frequency because the development of a leading-edge vortex during the stroke is delayed at the high reduced frequency. Increasing the aspect ratio of the hydrofoil leads to a higher contribution to efficiency from heaving over the range of aspect ratios considered in this study. However, the effect of the aspect ratio on efficiency from pitching is negligible. When end plates are mounted at both ends of the hydrofoil, heaving power enhances. However, the enhancement of heaving power becomes smaller with increasing aspect ratio. Meanwhile, pitching power improves uniformly with the addition of end plates for all three aspect ratios. Our study suggests that the dependence of energy harvesting performance on aspect ratio is due to the delayed growth of the leading-edge vortex near the ends of the hydrofoil.